From 8adc3868633511bf3ecdb54e6938af8870ecfc47 Mon Sep 17 00:00:00 2001 From: "Hein Puth (Warkanum)" <208308+warkanum@users.noreply.github.com> Date: Tue, 30 Dec 2025 12:58:38 +0200 Subject: [PATCH] Update pkg/server/manager.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- pkg/server/manager.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/server/manager.go b/pkg/server/manager.go index b4d4d8f..c21c93f 100644 --- a/pkg/server/manager.go +++ b/pkg/server/manager.go @@ -217,8 +217,14 @@ func (sm *serverManager) Remove(name string) error { return fmt.Errorf("server with name '%s' not found", name) } - // Stop the server if it's running - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + // Stop the server if it's running. Prefer the server's configured shutdownTimeout + // when available, and fall back to a sensible default. + timeout := 10 * time.Second + if gs, ok := instance.(*gracefulServer); ok && gs.shutdownTimeout > 0 { + timeout = gs.shutdownTimeout + } + + ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() if err := instance.Stop(ctx); err != nil { logger.Warn("Failed to gracefully stop server '%s' on remove: %v", name, err)