diff --git a/servlet.go b/servlet.go index 99a9482..76d3885 100644 --- a/servlet.go +++ b/servlet.go @@ -81,6 +81,13 @@ func (s *rpcServlet) Start(parentCTX cuc.Context, conn interface{}, doneChan cha } func (s *rpcServlet) Stop() { + if s.stopChan == nil { + logging.Logger().Warn("Server: server must be started before stopping it") + return + } + + close(s.stopChan) + s.destroy(nil) } @@ -103,12 +110,6 @@ func (s *rpcServlet) Context() ServletContext { } func (s *rpcServlet) destroy(err error) { - if s.stopChan == nil { - logging.Logger().Warn("Server: server must be started before stopping it") - return - } - - close(s.stopChan) s.stopWg.Wait() s.sh.Destroy(s.ctx)