var os = require('os'); var cluster = require('cluster'); cluster.setupMaster({ exec: 'app.js' }); cluster.on('exit', function(worker) { console.log('worker ' + worker.id + ' died'); cluster.fork(); }); for (var i = 0; i < os.cpus().length; i++) { cluster.fork(); }