ADd consul support , multiple monitors, config file

This commit is contained in:
Mayuresh Gaitonde
2018-10-25 22:23:04 -07:00
parent e20f691de5
commit 6fafdbbd16
11 changed files with 441 additions and 85 deletions

14
main.go
View File

@@ -3,27 +3,23 @@ package main
import (
"context"
"flag"
c "github.com/mayuresh82/gocast/config"
"github.com/mayuresh82/gocast/controller"
"github.com/mayuresh82/gocast/server"
"os"
"os/signal"
"syscall"
"time"
)
var (
serverAddr = flag.String("serverAddr", ":8080", "Addr for http service")
localAS = flag.Int("localAS", 65000, "Local ASN of the gocast host")
peerAS = flag.Int("peerAS", 65254, "AS to peer with")
monitorInterval = flag.Duration("monitorInterval", 5*time.Second, "Interval for health check")
peerIP = flag.String("peerIP", "", "Override the IP to peer with. Default: gateway ip")
cleanupTimer = flag.Duration("cleanup", 15*time.Minute, "Time to flush out inactive apps")
config = flag.String("config", "", "Path to config file")
)
func main() {
flag.Parse()
mon := controller.NewMonitor(*localAS, *peerAS, *monitorInterval, *peerIP, *cleanupTimer)
srv := server.NewServer(*serverAddr, mon)
conf := c.GetConfig(*config)
mon := controller.NewMonitor(conf)
srv := server.NewServer(conf.Agent.ListenAddr, mon)
ctx, cancel := context.WithCancel(context.Background())
// catch interrupt