From f4ef9cab5b201e79bf9f73cd7eb7f2ef64f03b0c Mon Sep 17 00:00:00 2001 From: Eli Young Date: Tue, 23 Jul 2019 00:41:11 -0700 Subject: [PATCH] Close database connections last on shutdown (#11683) The job workers and cluster discovery components require access to the database during shutdown. To avoid issues, we leave the database open until the last step of the shutdown process. --- app/server.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/server.go b/app/server.go index e6a7b9d78d..3850b47793 100644 --- a/app/server.go +++ b/app/server.go @@ -332,10 +332,6 @@ func (s *Server) Shutdown() error { s.StopHTTPServer() s.WaitForGoroutines() - if s.Store != nil { - s.Store.Close() - } - if s.htmlTemplateWatcher != nil { s.htmlTemplateWatcher.Close() } @@ -358,6 +354,10 @@ func (s *Server) Shutdown() error { s.Jobs.StopSchedulers() } + if s.Store != nil { + s.Store.Close() + } + mlog.Info("Server stopped") return nil }