-
Notifications
You must be signed in to change notification settings - Fork 308
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
En/graceful shutdown config #1529
base: development
Are you sure you want to change the base?
Conversation
…ul_shutdown_config
// Goroutine to handle shutdown when context is canceled | ||
go func() { | ||
<-ctx.Done() | ||
|
||
// Create a shutdown context with a timeout | ||
shutdownCtx, done := context.WithTimeout(context.WithoutCancel(ctx), shutDownTimeout) | ||
shutdownCtx, done := context.WithTimeout(context.Background(), timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did we change the context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the original code, context.WithoutCance
l was used to ensure the shutdown process had a fixed timeout (shutDownTimeout) to complete before termination.
In the updated code, the getShutdownTimeoutFromConfig
function fetches the shutdown timeout from the configuration, allowing it to be configurable.
If context.WithCancel
were used instead, the shutdown context would be canceled when the parent context is canceled, potentially cutting short the shutdown process and not respecting the full timeout value.
Pull Request Template
Description:
SERVER_SHUTDOWN_THRESHOLD
to change the default graceful shutdown timeout from 30sec.Checklist:
goimport
andgolangci-lint
.Thank you for your contribution!