Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: Add SIGHUP and SIGTERM handling to coder server #3543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 18, 2022

Conversation

mafredri
Copy link
Member

To prevent additional signals from aborting program execution, signal
handling was moved to the beginning of the main function, this ensures
that signals stays registered for the entire shutdown procedure.

Fixes #1529

To prevent additional signals from aborting program execution, signal
handling was moved to the beginning of the main function, this ensures
that signals stays registered for the entire shutdown procedure.

Fixes #1529
@mafredri mafredri self-assigned this Aug 18, 2022
@mafredri mafredri requested a review from a team August 18, 2022 08:53
//
// To get out of a graceful shutdown, the user can send
// SIGQUIT with ctrl+\ or SIGKILL with `kill -9`.
notifyCtx, notifyStop := signal.NotifyContext(ctx, interruptSignals...)
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: Naming this notifyCtx here means that during startup, and interrupt signal won't abort the process up until we start listening <-notifyCtx.Done().

The reason for this is that we have certain services that begin their shutdown procedure on context cancellation, but we want to control the order in which things are shut down.

I think it's acceptable that after starting, ctrl+c won't close coder server until the initial startup sequence is complete. But it's possible to work around this by monitoring the notifyCtx separately for parts of the startup where we want an early exit.

@mafredri mafredri merged commit 6a0f8ae into main Aug 18, 2022
@mafredri mafredri deleted the mafredri/server-signal-handling branch August 18, 2022 13:25
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.

Coder server does not exit gracefully after single SIGHUP or SIGTERM
3 participants