Skip to content

Instantly share code, notes, and snippets.

@andrewrk
Forked from BorePlusPlus/cluster-sig.js
Created August 12, 2013 16:11
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 andrewrk/6212372 to your computer and use it in GitHub Desktop.
Save andrewrk/6212372 to your computer and use it in GitHub Desktop.
var cluster = require('cluster');
if (cluster.isMaster) {
cluster.fork();
cluster.on('exit', function(worker, code, signal) {
console.log('Worker exited:', worker.process.pid);
});
setTimeout(function () {
for (var id in cluster.workers) {
var worker = cluster.workers[id];
process.kill(worker.pid, 'SIGUSR2');
}
}, 2000);
} else {
process.on('SIGUSR2', function() {
//WHY DOES THIS NOT GET CALLED? http://nodejs.org/api/cluster.html
console.log('SIGUSR2 called', process.pid);
});
console.log('Worker listening for SIGUSR2', process.pid);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment