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
[Issue #7] Add support for graceful shutdowns. #21
Conversation
Although I don't have time to review this right this second, I'm not ashamed to say I want to hug you for contributing this, and so quickly. Thanks @sean! |
Update Application Life Cycle Docs
Awesome 👍 Shouldn't the server return a 503 instead of a 502 in this case? Also, either as part of this or as a subsequent commit we should enable a template to be loaded from |
return next(); | ||
} | ||
res.setHeader("Connection", "close"); | ||
res.send(502, "Server is in the process of restarting."); |
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.
Agree with the team.
Thanks!
Just one very minor nitpick:
Should say "shutting down" instead of restarting.
Good catch, that was a typo, I've corrected it in the most recent patch. Now it sets a status of 503 (Service Unavailable) and renders the errorPages['503'] template if defined. |
res.status(503); | ||
res.render(template); | ||
} else { | ||
res.send(503, "Server is in the process of restarting."); |
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.
Agree with the team.
Thanks!
Just a minor nitpick on this line: Should it say "shutting down" instead of "restarting"?
Thanks @sean. Just a few nitpicks/thoughts. In index.js can you please either 1) move the I see there's mixed single and double quotes in some places. The coding style for kraken-js is single quotes everywhere. Should the I know we don't (yet) have logging integrated into kraken, but can you please remove the Can we make the shutdown-timeout configurable with 30 seconds as a default? |
@totherik I've incorporated all of the review feedback and the pull request has been updated. Thanks! |
Two more nitpicks and then I think we're good:
|
I like it 👍 |
[Issue #7] Add support for graceful shutdowns.
Thanks @jeffharrell! |
Missed reference to old webcore-appsec
With this change hitting Control+C or sending kill -{2,15} (SIGINT or SIGTERM) will cause the server to shutdown gracefully draining any connections. Clients which connect will see this message:
If the connections are drained successfully prior to the timeout, stdout will display:
and the exit code will be 0. Otherwise you'll see:
and the exit code will be 1. The timeout is hardcoded at 30s, perhaps this should be configurable.