overflow_discovery/main.go

64 lines
904 B
Go
Raw Normal View History

2017-10-26 12:55:55 +00:00
package main
import (
2017-10-27 06:01:09 +00:00
"flag"
"os"
"os/signal"
"syscall"
2017-10-26 12:55:55 +00:00
2017-11-15 06:59:43 +00:00
"git.loafle.net/commons_go/logging"
2018-03-21 10:34:40 +00:00
oocc "git.loafle.net/overflow/overflow_commons_go/config"
2017-10-26 12:55:55 +00:00
"git.loafle.net/overflow/overflow_discovery/server"
)
2017-10-27 06:01:09 +00:00
var (
2018-03-21 10:34:40 +00:00
pidPath *string
logConfigPath *string
2017-10-27 06:01:09 +00:00
)
func init() {
2018-03-21 10:34:40 +00:00
pidPath = oocc.FlagPidFilePath("./dist/discovery.pid")
logConfigPath = oocc.FlagLogConfigFilePath("")
2017-10-27 06:01:09 +00:00
flag.Parse()
2018-03-21 10:34:40 +00:00
logging.InitializeLogger(*logConfigPath)
2017-10-27 06:01:09 +00:00
}
2017-10-26 12:55:55 +00:00
func main() {
2017-11-15 06:59:43 +00:00
defer logging.Logger().Sync()
2017-10-26 12:55:55 +00:00
2017-12-14 08:55:57 +00:00
s := server.New(*pidPath)
2017-10-26 12:55:55 +00:00
2017-10-27 06:01:09 +00:00
stop := make(chan os.Signal)
signal.Notify(stop, syscall.SIGINT)
2017-10-26 12:55:55 +00:00
2017-10-27 06:01:09 +00:00
go func() {
2017-11-15 06:59:43 +00:00
if err := s.Start(); nil != err {
2018-03-21 10:34:40 +00:00
logging.Logger().Infof("Server: Start error %v", err)
2017-10-27 06:01:09 +00:00
return
}
}()
2017-10-26 12:55:55 +00:00
2017-10-27 06:01:09 +00:00
select {
case signal := <-stop:
2018-03-21 10:34:40 +00:00
logging.Logger().Infof("Got signal: %v\n", signal)
2017-10-26 12:55:55 +00:00
}
2017-11-15 06:59:43 +00:00
2017-10-27 06:01:09 +00:00
s.Stop()
2017-10-26 12:55:55 +00:00
}
/**
azure
consul
dns
ec2
file
gce
kubernetes
marathon
openstack
triton
zookeeper
*/