~emersion/soju

027a89a0b0b3481ad85c9c0e61b4b0464f5b0057 — Simon Ser 18 days ago d354c73
server: log when waiting for user goroutines on shutdown

Useful for debugging.
2 files changed, 3 insertions(+), 1 deletions(-)

M cmd/soju/main.go
M server.go
M cmd/soju/main.go => cmd/soju/main.go +0 -1
@@ 335,7 335,6 @@ func main() {
				srv.SetConfig(serverCfg)
			}
		case syscall.SIGINT, syscall.SIGTERM:
			log.Print("shutting down server")
			srv.Shutdown()
			return
		}

M server.go => server.go +3 -0
@@ 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 {