This commit is contained in:
crusader 2018-03-22 21:31:47 +09:00
parent ffeccef8d8
commit ba6bb15295

View File

@ -52,18 +52,22 @@ func (sh *ServerHandlers) Listen(serverCTX server.ServerContext) (net.Listener,
func (sh *ServerHandlers) OnStart(serverCTX server.ServerContext) { func (sh *ServerHandlers) OnStart(serverCTX server.ServerContext) {
sh.ServerHandlers.OnStart(serverCTX) sh.ServerHandlers.OnStart(serverCTX)
if _, err := os.Stat(sh.pidPath); os.IsExist(err) {
if err := os.Remove(sh.pidPath); nil != err { if err := os.Remove(sh.pidPath); nil != err {
logging.Logger().Errorf("Container: Removing pid file has been failed [%v]", err) logging.Logger().Errorf("Container: Removing pid file has been failed [%v]", err)
} }
}
s := strconv.FormatInt(int64(sh.port), 10) s := strconv.FormatInt(int64(sh.port), 10)
ioutil.WriteFile(sh.pidPath, []byte(s), os.ModePerm) ioutil.WriteFile(sh.pidPath, []byte(s), os.ModePerm)
} }
func (sh *ServerHandlers) OnStop(serverCTX server.ServerContext) { func (sh *ServerHandlers) OnStop(serverCTX server.ServerContext) {
if _, err := os.Stat(sh.pidPath); os.IsExist(err) {
if err := os.Remove(sh.pidPath); nil != err { if err := os.Remove(sh.pidPath); nil != err {
logging.Logger().Errorf("Container: Removing pid file has been failed [%v]", err) logging.Logger().Errorf("Container: Removing pid file has been failed [%v]", err)
} }
}
sh.ServerHandlers.OnStop(serverCTX) sh.ServerHandlers.OnStop(serverCTX)
} }