From 70da0e7f122b84f88037f03f5a70ac85e7b8f2d8 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 12 Jun 2019 08:11:43 +0000 Subject: [PATCH 1/2] Leave Server module running until end of shutdown We want the process to answer requests (including status and metrics) until it has finished shutting down. Every target depends on Server, so it will get shut down as a dependency. Signed-off-by: Bryan Boreham --- pkg/cortex/cortex.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/cortex/cortex.go b/pkg/cortex/cortex.go index 53ac96c394b..c9c42f3f99b 100644 --- a/pkg/cortex/cortex.go +++ b/pkg/cortex/cortex.go @@ -221,7 +221,6 @@ func (t *Cortex) Run() error { // Stop gracefully stops a Cortex. func (t *Cortex) Stop() error { - t.server.Shutdown() t.stop(t.target) return nil } From 473b333b02c3d2e8a0daa8cbf1e4895726093129 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 12 Jun 2019 14:10:21 +0000 Subject: [PATCH 2/2] Elide stop() function into its caller Signed-off-by: Bryan Boreham --- pkg/cortex/cortex.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/cortex/cortex.go b/pkg/cortex/cortex.go index c9c42f3f99b..7c446768e9c 100644 --- a/pkg/cortex/cortex.go +++ b/pkg/cortex/cortex.go @@ -221,17 +221,13 @@ func (t *Cortex) Run() error { // Stop gracefully stops a Cortex. func (t *Cortex) Stop() error { - t.stop(t.target) - return nil -} - -func (t *Cortex) stop(m moduleName) { - t.stopModule(m) - deps := orderedDeps(m) + t.stopModule(t.target) + deps := orderedDeps(t.target) // iterate over our deps in reverse order and call stopModule for i := len(deps) - 1; i >= 0; i-- { t.stopModule(deps[i]) } + return nil } func (t *Cortex) stopModule(m moduleName) {