-
-
Save sam-github/7645421 to your computer and use it in GitHub Desktop.
show how to deliver SIGTERM to a cluster worker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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