Periodically flush stats.json

This commit is contained in:
Eugene Bujak 2018-10-04 14:25:40 +03:00
parent 51ec58b0ce
commit 856e26edcf

11
app.go
View File

@ -9,6 +9,7 @@ import (
"os/signal"
"path/filepath"
"strconv"
"time"
"github.com/gobuffalo/packr"
)
@ -132,6 +133,16 @@ func main() {
os.Exit(1)
}()
go func() {
for range time.Tick(time.Hour * 24) {
err := writeStats()
if err != nil {
log.Printf("Couldn't write stats: %s", err)
// try later on next iteration, don't abort
}
}
}()
address := net.JoinHostPort(config.BindHost, strconv.Itoa(config.BindPort))
runStatsCollectors()