Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Catch SIGTERM to gracefully clean up child processes & exit #25

Merged
merged 1 commit into from

2 participants

@lmorchard

This is a fix for the recurring restart issues we've been having for kumascript in production. The parent process wasn't gracefully exiting on kill -TERM, and instead just said "see ya suckers" and orphaned all the child processes.

@lmorchard lmorchard referenced this pull request in mozilla/kuma
Merged

KumaScript update to gracefully exit on SIGTERM #917

@groovecoder
Owner

r+ for both

@groovecoder groovecoder merged commit b57f7b5 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 1 deletion.
  1. +8 −1 run.js
View
9 run.js
@@ -144,7 +144,14 @@ function runMaster () {
process.exit(0);
}
- process.on('SIGINT', performExit);
+ process.on('SIGINT', function (err) {
+ log.info("Received SIGINT, exiting...");
+ performExit();
+ });
+ process.on('SIGTERM', function (err) {
+ log.info("Received SIGTERM, exiting...");
+ performExit();
+ });
process.on('uncaughtException', function (err) {
statsd.increment('kumascript.master_exceptions');
log.error('uncaughtException:', err.message);
Something went wrong with that request. Please try again.