From 0d4436edba60b852e2882fc46e1f274afc03c054 Mon Sep 17 00:00:00 2001 From: John Shahid Date: Tue, 4 Nov 2014 15:23:29 -0500 Subject: [PATCH] Make sure all services are stopped properly --- server/server.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/server.go b/server/server.go index b452785af88..b5a5f26893c 100644 --- a/server/server.go +++ b/server/server.go @@ -263,10 +263,6 @@ func (self *Server) Stop() { log.Info("Stopping server") self.stopped = true - log.Info("Stopping api server") - self.HttpApi.Close() - log.Info("Api server stopped") - if self.Config.GraphiteEnabled { log.Info("Stopping GraphiteServer") self.GraphiteApi.Close() @@ -292,4 +288,11 @@ func (self *Server) Stop() { log.Info("Stopping shard store") self.shardStore.Close() log.Info("shard store stopped") + + // HttpApi should be the last server to be closed, otherwise + // server.ListenAndServe() will return causing main() to exit before + // the other services are properly stopped + log.Info("Stopping api server") + self.HttpApi.Close() + log.Info("Api server stopped") }