datas for aliases (later

This commit is contained in:
Martin Geno 2016-02-25 21:42:58 +01:00
parent 41b33a2041
commit 70ae82da79
1 changed files with 13 additions and 9 deletions

12
main.go
View File

@ -21,7 +21,9 @@ var (
wsserverForNodes = websocketserver.NewServer("/nodes") wsserverForNodes = websocketserver.NewServer("/nodes")
responedDaemon *responed.Daemon responedDaemon *responed.Daemon
nodes = models.NewNodes() nodes = models.NewNodes()
outputFile string aliases = models.NewNodes()
outputNodesFile string
outputAliasesFile string
collectInterval time.Duration collectInterval time.Duration
saveInterval time.Duration saveInterval time.Duration
) )
@ -29,16 +31,18 @@ var (
func main() { func main() {
var collectSeconds, saveSeconds int var collectSeconds, saveSeconds int
flag.StringVar(&outputFile, "output", "webroot/nodes.json", "path output file") flag.StringVar(&outputNodesFile, "output", "webroot/nodes.json", "path nodes.json file")
flag.IntVar(&collectSeconds, "collectInterval", 15, "interval for data collections") flag.StringVar(&outputAliasesFile, "aliases", "webroot/aliases.json", "path aliases.json file")
flag.IntVar(&saveSeconds, "saveInterval", 5, "interval for data saving") flag.IntVar(&saveSeconds, "saveInterval", 5, "interval for data saving")
flag.IntVar(&collectSeconds, "collectInterval", 15, "interval for data collections")
flag.Parse() flag.Parse()
collectInterval = time.Second * time.Duration(collectSeconds) collectInterval = time.Second * time.Duration(collectSeconds)
saveInterval = time.Second * time.Duration(saveSeconds) saveInterval = time.Second * time.Duration(saveSeconds)
go wsserverForNodes.Listen() go wsserverForNodes.Listen()
go nodes.Saver(outputFile, saveInterval) go nodes.Saver(outputNodesFile, saveInterval)
go aliases.Saver(outputAliasesFile, saveInterval)
responedDaemon = responed.NewDaemon(func(coll *responed.Collector, res *responed.Response) { responedDaemon = responed.NewDaemon(func(coll *responed.Collector, res *responed.Response) {
var result map[string]interface{} var result map[string]interface{}
json.Unmarshal(res.Raw, &result) json.Unmarshal(res.Raw, &result)