overflow_discovery/main.go
crusader dc520fdb24 ing
2017-10-27 15:01:09 +09:00

65 lines
940 B
Go

package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
cRPC "git.loafle.net/commons_go/rpc"
"git.loafle.net/commons_go/rpc/protocol/json"
"git.loafle.net/overflow/overflow_discovery/rpc"
"git.loafle.net/overflow/overflow_discovery/server"
)
var (
sockFile *string
)
func init() {
sockFile = flag.String("sock", serverAddr, "Socket file")
flag.Parse()
}
func main() {
registry := cRPC.NewRegistry()
registry.RegisterCodec(json.NewCodec(), "json")
registry.RegisterService(new(rpc.DiscoveryService), "")
s := server.New(*sockFile, registry)
stop := make(chan os.Signal)
signal.Notify(stop, syscall.SIGINT)
go func() {
if err := s.Serve(); err != nil {
log.Fatalf("Cannot start rpc server: %s", err)
return
}
}()
select {
case signal := <-stop:
fmt.Printf("Got signal: %v\n", signal)
}
s.Stop()
}
/**
azure
consul
dns
ec2
file
gce
kubernetes
marathon
openstack
triton
zookeeper
*/