server: log when waiting for user goroutines on shutdown
Useful for debugging.
This commit is contained in:
parent
d354c73933
commit
027a89a0b0
@ -335,7 +335,6 @@ func main() {
|
|||||||
srv.SetConfig(serverCfg)
|
srv.SetConfig(serverCfg)
|
||||||
}
|
}
|
||||||
case syscall.SIGINT, syscall.SIGTERM:
|
case syscall.SIGINT, syscall.SIGTERM:
|
||||||
log.Print("shutting down server")
|
|
||||||
srv.Shutdown()
|
srv.Shutdown()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -343,6 +343,8 @@ func (s *Server) sendWebPush(ctx context.Context, sub *webpush.Subscription, vap
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) Shutdown() {
|
func (s *Server) Shutdown() {
|
||||||
|
s.Logger.Printf("shutting down server")
|
||||||
|
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
s.shutdown = true
|
s.shutdown = true
|
||||||
for ln := range s.listeners {
|
for ln := range s.listeners {
|
||||||
@ -355,6 +357,7 @@ func (s *Server) Shutdown() {
|
|||||||
}
|
}
|
||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
|
|
||||||
|
s.Logger.Printf("waiting for users to finish")
|
||||||
s.stopWG.Wait()
|
s.stopWG.Wait()
|
||||||
|
|
||||||
if err := s.db.Close(); err != nil {
|
if err := s.db.Close(); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user