Skip to content

SIGTERM is now graceful, the same as SIGINT. - #50

Merged
ioquatix merged 13 commits into
mainfrom
graceful-terminate
Feb 4, 2026
Merged

ioquatix merged 13 commits into
mainfrom
graceful-terminate

Conversation

@samuel-williams-shopify

@samuel-williams-shopify samuel-williams-shopify commented Feb 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #49.

Types of Changes

  • Bug fix.
  • Breaking change.

Contribution

# $stderr.puts "Received TERM signal, terminating...", caller
::Thread.current.raise(Terminate)
# $stderr.puts "Received TERM signal, interrupting...", caller
::Thread.current.raise(Interrupt) # Same as SIGINT

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not change the rescue Terminate block instead of changing the raised exception?

@samuel-williams-shopify samuel-williams-shopify Feb 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be possible, but Async itself specifically handles Interrupt differently from Terminate.

Interrupt triggers a graceful stop of the Async scheduler: https://github.com/socketry/async/blob/400bc2e1fedcaa72ae1fa86d5c8d7e1962c1f889/lib/async/scheduler.rb#L534-L543

I think we want to preserve this behaviour, and if we raised Terminate it would cause an ungraceful exit.

Later on, I think we can revisit this if necessary.

Comment thread lib/async/container/generic.rb Resolved
Comment thread lib/async/container/generic.rb Resolved
Comment thread test/async/container/controller.rb Resolved
@ioquatix
ioquatix merged commit e333ae5 into main Feb 4, 2026
40 of 48 checks passed
@ioquatix
ioquatix deleted the graceful-terminate branch February 4, 2026 04:00
@ioquatix ioquatix added this to the v0.30.0 milestone Feb 4, 2026
@udipl udipl mentioned this pull request May 22, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Graceful shutdown on kubernetes

3 participants