Clarified file configuration naming
This commit is contained in:
parent
c28c848b95
commit
617e025be4
@ -1,6 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
type SmonConfiguration struct {
|
type FileConfiguration struct {
|
||||||
LogFile string
|
LogFile string
|
||||||
NodataInterval int `json:"nodata_interval"` // in seconds
|
NodataInterval int `json:"nodata_interval"` // in seconds
|
||||||
}
|
}
|
||||||
|
8
main.go
8
main.go
@ -39,7 +39,7 @@ var (
|
|||||||
parsedTemplates map[string]*template.Template
|
parsedTemplates map[string]*template.Template
|
||||||
componentFilenames []string
|
componentFilenames []string
|
||||||
notificationManager notification.Manager
|
notificationManager notification.Manager
|
||||||
smonConf SmonConfiguration
|
fileConf FileConfiguration
|
||||||
|
|
||||||
//go:embed sql
|
//go:embed sql
|
||||||
sqlFS embed.FS
|
sqlFS embed.FS
|
||||||
@ -91,13 +91,13 @@ func main() { // {{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
j, _ := json.Marshal(service.Config.Application)
|
j, _ := json.Marshal(service.Config.Application)
|
||||||
json.Unmarshal(j, &smonConf)
|
json.Unmarshal(j, &fileConf)
|
||||||
logFile, err = os.OpenFile(smonConf.LogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
|
logFile, err = os.OpenFile(fileConf.LogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("application", "error", err)
|
logger.Error("application", "error", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if smonConf.NodataInterval < 10 {
|
if fileConf.NodataInterval < 10 {
|
||||||
logger.Error("application → nodata_interval has to be larger or equal to 10.")
|
logger.Error("application → nodata_interval has to be larger or equal to 10.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,7 @@ func nodataLoop() {
|
|||||||
var datapoints []Datapoint
|
var datapoints []Datapoint
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// TODO - should be configurable
|
ticker := time.NewTicker(time.Second * time.Duration(fileConf.NodataInterval))
|
||||||
ticker := time.NewTicker(time.Second * time.Duration(smonConf.NodataInterval))
|
|
||||||
for {
|
for {
|
||||||
<-ticker.C
|
<-ticker.C
|
||||||
datapoints, err = nodataDatapoints()
|
datapoints, err = nodataDatapoints()
|
||||||
|
Loading…
Reference in New Issue
Block a user