diff --git a/server/server_handlers.go b/server/server_handlers.go index 7a0d15e..631cfd9 100644 --- a/server/server_handlers.go +++ b/server/server_handlers.go @@ -52,8 +52,10 @@ func (sh *ServerHandlers) Listen(serverCTX server.ServerContext) (net.Listener, func (sh *ServerHandlers) OnStart(serverCTX server.ServerContext) { sh.ServerHandlers.OnStart(serverCTX) - if err := os.Remove(sh.pidPath); nil != err { - logging.Logger().Errorf("Container: Removing pid file has been failed [%v]", err) + if _, err := os.Stat(sh.pidPath); os.IsExist(err) { + if err := os.Remove(sh.pidPath); nil != err { + logging.Logger().Errorf("Container: Removing pid file has been failed [%v]", err) + } } s := strconv.FormatInt(int64(sh.port), 10) @@ -61,8 +63,10 @@ func (sh *ServerHandlers) OnStart(serverCTX server.ServerContext) { } func (sh *ServerHandlers) OnStop(serverCTX server.ServerContext) { - if err := os.Remove(sh.pidPath); nil != err { - logging.Logger().Errorf("Container: Removing pid file has been failed [%v]", err) + if _, err := os.Stat(sh.pidPath); os.IsExist(err) { + if err := os.Remove(sh.pidPath); nil != err { + logging.Logger().Errorf("Container: Removing pid file has been failed [%v]", err) + } } sh.ServerHandlers.OnStop(serverCTX)