overflow_discovery/main.go

61 lines
750 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"
"fmt"
2017-10-26 12:55:55 +00:00
"log"
2017-10-27 06:01:09 +00:00
"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"
2017-10-26 12:55:55 +00:00
"git.loafle.net/overflow/overflow_discovery/server"
)
2017-10-27 06:01:09 +00:00
var (
2017-12-14 08:55:57 +00:00
pidPath *string
2017-10-27 06:01:09 +00:00
)
func init() {
2017-12-14 08:55:57 +00:00
pidPath = flag.String("pid-path", "/tmp/discovery-container.pid", "The path of pid file")
2017-10-27 06:01:09 +00:00
flag.Parse()
}
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 {
log.Printf("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:
fmt.Printf("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
*/