Skip to content

Commit

Permalink
remove 5 seconds delay before force kill
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelvigee committed Apr 17, 2024
1 parent b305844 commit 48347c4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions utils/xcontext/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit 48347c4

Please sign in to comment.