server: log when waiting for user goroutines on shutdown

Useful for debugging.
This commit is contained in:
Simon Ser 2022-09-18 21:43:31 +02:00
parent d354c73933
commit 027a89a0b0
2 changed files with 3 additions and 1 deletions

View File

@ -335,7 +335,6 @@ func main() {
srv.SetConfig(serverCfg)
}
case syscall.SIGINT, syscall.SIGTERM:
log.Print("shutting down server")
srv.Shutdown()
return
}

View File

@ -343,6 +343,8 @@ func (s *Server) sendWebPush(ctx context.Context, sub *webpush.Subscription, vap
}
func (s *Server) Shutdown() {
s.Logger.Printf("shutting down server")
s.lock.Lock()
s.shutdown = true
for ln := range s.listeners {
@ -355,6 +357,7 @@ func (s *Server) Shutdown() {
}
s.lock.Unlock()
s.Logger.Printf("waiting for users to finish")
s.stopWG.Wait()
if err := s.db.Close(); err != nil {