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-10-27 06:01:09 +00:00
|
|
|
cRPC "git.loafle.net/commons_go/rpc"
|
|
|
|
"git.loafle.net/overflow/overflow_discovery/rpc"
|
2017-10-26 12:55:55 +00:00
|
|
|
"git.loafle.net/overflow/overflow_discovery/server"
|
|
|
|
)
|
|
|
|
|
2017-10-27 06:01:09 +00:00
|
|
|
var (
|
|
|
|
sockFile *string
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
sockFile = flag.String("sock", serverAddr, "Socket file")
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-10-26 12:55:55 +00:00
|
|
|
func main() {
|
2017-10-27 06:01:09 +00:00
|
|
|
registry := cRPC.NewRegistry()
|
|
|
|
registry.RegisterService(new(rpc.DiscoveryService), "")
|
2017-10-26 12:55:55 +00:00
|
|
|
|
2017-10-27 06:01:09 +00:00
|
|
|
s := server.New(*sockFile, registry)
|
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() {
|
|
|
|
if err := s.Serve(); err != nil {
|
|
|
|
log.Fatalf("Cannot start rpc server: %s", err)
|
|
|
|
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-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
|
|
|
|
*/
|