Created
March 12, 2015 15:30
-
-
Save parsingphase/40c81086903df8967808 to your computer and use it in GitHub Desktop.
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
console.log('Start...'); | |
var cluster = require('cluster'); | |
console.log('required'); | |
var isMaster = cluster.isMaster; | |
console.log('isMaster? ' + isMaster); | |
if (isMaster) { | |
// Listen for dying workers | |
cluster.on('exit', function (worker) { | |
// Replace the dead worker, | |
// we're not sentimental | |
console.log('Worker ' + worker.id + ' died, replacing'); | |
cluster.fork(); | |
}); | |
console.log('Forking first worker'); | |
cluster.fork(); // if this is all we do, we hang around indefinitely? | |
} else { | |
setTimeout(function () { | |
throw new Error('dead'); | |
}, 3000); | |
} | |
console.log('EOF'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment