test.standalone.js 357 B

12345678910111213141516171819202122
  1. /**
  2. * Module dependencies.
  3. */
  4. var cluster = require('../');
  5. require('./common');
  6. cluster = cluster()
  7. .set('workers', 2)
  8. .start();
  9. if (cluster.isWorker) {
  10. setTimeout(process.exit, Math.random() * 300);
  11. } else {
  12. // make sure workers are re-spawned
  13. var n = 12;
  14. cluster.on('worker killed', function(worker){
  15. --n || process.exit();
  16. });
  17. }