server.js 276 B

123456789101112131415
  1. var os = require('os');
  2. var cluster = require('cluster');
  3. cluster.setupMaster({
  4. exec: 'app.js'
  5. });
  6. cluster.on('exit', function(worker) {
  7. console.log('worker ' + worker.id + ' died');
  8. cluster.fork();
  9. });
  10. for (var i = 0; i < os.cpus().length; i++) {
  11. cluster.fork();
  12. }