-
Notifications
You must be signed in to change notification settings - Fork 42
Shutdown/Cancel interface, "Deactivate" #71
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
Conversation
| done := make(chan struct{}) | ||
| go func() { | ||
| as.wg.Wait() | ||
| close(done) | ||
| }() | ||
|
|
||
| select { | ||
| case <-done: | ||
| as.logger.Info("Admin server shutdown complete") | ||
| case <-ctx.Done(): | ||
| as.logger.Warn("Admin server shutdown timed out") | ||
| } | ||
|
|
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.
It turns out that Shutdown on http.Server is non blocking and graceful, i.e., it doesn't terminate existing connections. Waiting on the goroutine that started it to be done is a clean(er) way to wait for the server's full termination.
| c.logger.Info("Queue runner completed") | ||
| c.queueRunner = nil | ||
| case <-time.After(timeout): | ||
| c.logger.Warn("Timeout waiting for queue runner to complete", "timeout", 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.
we cannot safely set the pointer to nil in case of timeout: the resource might yet to be accessed, which would cause a panic.
Uh oh!
There was an error while loading. Please reload this page.