This commit is contained in:
crusader 2017-12-01 22:13:15 +09:00
parent 933fb0d87a
commit af27365039

View File

@ -47,7 +47,7 @@ func (s *server) Start() error {
s.sh.Validate() s.sh.Validate()
if s.stopChan != nil { if s.stopChan != nil {
logging.Logger().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")
} }
s.httpServer = &fasthttp.Server{ s.httpServer = &fasthttp.Server{
@ -73,7 +73,7 @@ func (s *server) Start() error {
s.ctx = s.sh.ServerContext() s.ctx = s.sh.ServerContext()
if err = s.sh.Init(s.ctx); nil != err { 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)
} }
var listener net.Listener var listener net.Listener
@ -92,7 +92,8 @@ func (s *server) Start() error {
func (s *server) Stop() { func (s *server) Stop() {
if s.stopChan == nil { if s.stopChan == nil {
logging.Logger().Panic("Server: server must be started before stopping it") logging.Logger().Warn("Server: server must be started before stopping it")
return
} }
close(s.stopChan) close(s.stopChan)
s.stopWg.Wait() s.stopWg.Wait()