From c59b7179c3e5dbf76708e7463c8eb42975083d21 Mon Sep 17 00:00:00 2001 From: Emily Rowlands Date: Fri, 18 Jul 2025 13:56:52 +0000 Subject: [PATCH] fix(cmd/anubis): add signal handling to metrics server (#856) This fixes a bug that was introduced in 68b653b0, in which the call to metricsServer was passed a plain context.Background without signal handling. This commit adds back in the signal handling for the metrics server, as well as for the Thoth client and storage backend. Closes: #853 Signed-off-by: Emily Rowlands --- cmd/anubis/main.go | 9 ++++----- docs/docs/CHANGELOG.md | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/anubis/main.go b/cmd/anubis/main.go index 9cade6a..9eb2f54 100644 --- a/cmd/anubis/main.go +++ b/cmd/anubis/main.go @@ -263,7 +263,10 @@ func main() { return } - ctx := context.Background() + // install signal handler + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + defer stop() + wg := new(sync.WaitGroup) if *metricsBind != "" { @@ -414,10 +417,6 @@ func main() { log.Fatalf("can't construct libanubis.Server: %v", err) } - // install signal handler - ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) - defer stop() - var h http.Handler h = s h = internal.RemoteXRealIP(*useRemoteAddress, *bindNetwork, h) diff --git a/docs/docs/CHANGELOG.md b/docs/docs/CHANGELOG.md index a830548..1d479a1 100644 --- a/docs/docs/CHANGELOG.md +++ b/docs/docs/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +- Fix hanging on service restart ([#853](https://github.com/TecharoHQ/anubis/issues/853)) + ## v1.21.0: Minfilia Warde > Please, be at ease. You are among friends here.