diff --git a/server.go b/server.go index 81d5cdf..8fc1409 100644 --- a/server.go +++ b/server.go @@ -43,13 +43,13 @@ func (s *server) Start() error { s.sh.Validate() if s.stopChan != nil { - panic("Server: server is already running. Stop it before starting it again") + return fmt.Errorf("Server: server is already running. Stop it before starting it again") } var err error s.ctx = s.sh.ServerContext() if err = s.sh.Init(s.ctx); nil != err { - logging.Logger().Panic(fmt.Sprintf("Server: Initialization of server has been failed %v", err)) + return fmt.Errorf("Server: Initialization of server has been failed %v", err) } if s.listener, err = s.sh.Listen(s.ctx); nil != err { @@ -66,7 +66,8 @@ func (s *server) Start() error { func (s *server) Stop() { if s.stopChan == nil { - panic("Server: server must be started before stopping it") + logging.Logger().Warn("Server: server must be started before stopping it") + return } close(s.stopChan) s.stopWg.Wait()