From 48347c4d52e29bc1b0ccc67355bc4911cf6324e8 Mon Sep 17 00:00:00 2001 From: Raphael Vigee Date: Wed, 17 Apr 2024 14:26:54 +0100 Subject: [PATCH] remove 5 seconds delay before force kill --- utils/xcontext/context.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/xcontext/context.go b/utils/xcontext/context.go index d895ef2f..06f6bc04 100644 --- a/utils/xcontext/context.go +++ b/utils/xcontext/context.go @@ -141,7 +141,7 @@ func Cancel(ctx context.Context) { func BootstrapSoftCancel() (context.Context, context.CancelFunc) { ctx, cancel := context.WithCancel(context.Background()) - sigCh := make(chan os.Signal, 1) + sigCh := make(chan os.Signal) signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM) sc := newSoftCancelState() @@ -160,13 +160,12 @@ func BootstrapSoftCancel() (context.Context, context.CancelFunc) { }() select { case <-sigCh: - case <-time.After(5 * time.Second): } log.Warnf("Forcing cancellation...") hardCanceled = true sc.hardCancel() select { - // Wait for soft cancel to all be unregistered, should be instant, unless something is stuck + // Wait for soft cancel to all be unregistered, should be fast, unless something is stuck case <-sc.wait(): // Wait for graceful exit <-time.After(2 * time.Second)