1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-28 15:27:43 +00:00
FrankerFaceZ/socketserver/cmd/statsweb/statsweb.go

40 lines
919 B
Go
Raw Normal View History

2016-01-17 10:31:39 -08:00
package main
2016-01-17 11:11:21 -08:00
import (
"net/http"
"flag"
"github.com/clarkduvall/hyperloglog"
"time"
"bitbucket.org/stendec/frankerfacez/socketserver/server"
)
2016-01-17 10:31:39 -08:00
2016-01-17 11:11:21 -08:00
var configLocation = flag.String("config", "./config.json", "Location of the configuration file. Defaults to ./config.json")
var genConfig = flag.Bool("genconf", false, "Generate a new configuration file.")
var config ConfigFile
const ExitCodeBadConfig = 2
func main() {
flag.Parse()
if *genConfig {
makeConfig()
return
}
loadConfig()
http.ListenAndServe(config.ListenAddr, http.DefaultServeMux)
}
func combineDateRange(from time.Time, to time.Time, dest *hyperloglog.HyperLogLogPlus) error {
from = server.TruncateToMidnight(from)
to = server.TruncateToMidnight(to)
year, month, day := from.Date()
for current := from; current.Before(to); day = day + 1 {
current = time.Date(year, month, day, 0, 0, 0, 0, server.CounterLocation)
}
return nil
}