Skip to content

Instantly share code, notes, and snippets.

@sam-github
Created December 30, 2013 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sam-github/8185222 to your computer and use it in GitHub Desktop.
Save sam-github/8185222 to your computer and use it in GitHub Desktop.
var cluster = require('cluster');
if(cluster.isMaster) {
cluster.fork()
.on('online', function() {
this.disconnect();
});
} else {
process.on('internalMessage', function(msg) {
console.log('internalMsg', msg);
if(msg && msg.cmd && msg.cmd === 'NODE_CLUSTER_disconnect') {
// v0.10
console.log('disconnect request!');
}
if(msg && msg.cmd && msg.cmd === 'NODE_CLUSTER' && msg.act === 'disconnect') {
// v0.11
console.log('disconnect request!');
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment