From 6eda8f1594b6fd1b3155cd07868357fedac1c00f Mon Sep 17 00:00:00 2001 From: JackDoan Date: Mon, 13 Jul 2026 15:16:28 -0500 Subject: [PATCH] correctly shutdown the pprofserver --- main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 8cc1256f..4646c565 100644 --- a/main.go +++ b/main.go @@ -37,7 +37,16 @@ func Main(c *config.C, configTest bool, buildVersion string, l *slog.Logger, dev } //todo no merge - go http.ListenAndServe(":6060", nil) + pprofServer := &http.Server{Addr: ":6060", Handler: nil} + go func() { + pprofServer.ListenAndServe() + }() + + // Shut down the server when context is cancelled + go func() { + <-ctx.Done() + pprofServer.Shutdown(context.Background()) + }() // Print the config if in test, the exit comes later if configTest {