Skip to content

Instantly share code, notes, and snippets.

@sam-github
Created November 25, 2013 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sam-github/7645421 to your computer and use it in GitHub Desktop.
Save sam-github/7645421 to your computer and use it in GitHub Desktop.
show how to deliver SIGTERM to a cluster worker
assert = require('assert')
cluster = require('cluster');
if(cluster.isMaster) {
worker=cluster.fork();
worker.on('online', function() {
// pause, to give worker time to establish signal handler
setTimeout(function() {
worker.process.kill('SIGTERM')
}, 100);
});
} else {
process.on('SIGTERM', function() {
console.log('worker termination, what now?')
process.disconnect();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment