This commit is contained in:
crusader 2017-12-14 17:55:57 +09:00
parent 1dbb36ba57
commit 8239f564f7
5 changed files with 7 additions and 13 deletions

View File

@ -13,11 +13,11 @@ import (
) )
var ( var (
sockFile *string pidPath *string
) )
func init() { func init() {
sockFile = flag.String("sock", serverAddr, "Socket file") pidPath = flag.String("pid-path", "/tmp/discovery-container.pid", "The path of pid file")
flag.Parse() flag.Parse()
} }
@ -25,7 +25,7 @@ func init() {
func main() { func main() {
defer logging.Logger().Sync() defer logging.Logger().Sync()
s := server.New(*sockFile) s := server.New(*pidPath)
stop := make(chan os.Signal) stop := make(chan os.Signal)
signal.Notify(stop, syscall.SIGINT) signal.Notify(stop, syscall.SIGINT)

View File

@ -1,3 +0,0 @@
package main
var serverAddr string = "/tmp/discovery.sock"

View File

@ -1,3 +0,0 @@
package main
var serverAddr string = "discovery"

View File

@ -7,14 +7,14 @@ import (
oopcs "git.loafle.net/overflow/overflow_probe_container/server" oopcs "git.loafle.net/overflow/overflow_probe_container/server"
) )
func New(addr string) server.Server { func New(pidPath string) server.Server {
rpcRegistry := crr.NewRPCRegistry() rpcRegistry := crr.NewRPCRegistry()
service.RegisterRPC(rpcRegistry) service.RegisterRPC(rpcRegistry)
rpcSH := oopcs.NewRPCServletHandler(rpcRegistry) rpcSH := oopcs.NewRPCServletHandler(rpcRegistry)
socketHandler := newSocketHandler(rpcSH) socketHandler := newSocketHandler(rpcSH)
sh := newServerHandler(addr, socketHandler) sh := newServerHandler(pidPath, socketHandler)
s := oopcs.New(sh) s := oopcs.New(sh)
return s return s

View File

@ -6,9 +6,9 @@ import (
oopcs "git.loafle.net/overflow/overflow_probe_container/server" oopcs "git.loafle.net/overflow/overflow_probe_container/server"
) )
func newServerHandler(addr string, socketHandler SocketHandler) ServerHandler { func newServerHandler(pidPath string, socketHandler SocketHandler) ServerHandler {
sh := &ServerHandlers{} sh := &ServerHandlers{}
sh.ServerHandler = oopcs.NewServerHandler(addr, "Discovery Containter", socketHandler) sh.ServerHandler = oopcs.NewServerHandler(pidPath, "Discovery Containter", socketHandler)
return sh return sh
} }