run.js 468 B

1234567891011121314151617181920
  1. const cluster = require ( 'cluster' );
  2. if ( cluster.isMaster )
  3. {
  4. cluster.fork ( );
  5. cluster.on ( 'exit', function ( worker, code, signal )
  6. {
  7. console.log ( '[Info/cluster] restarting process after unhandled exception (in 8.5 seconds)' );
  8. setTimeout ( function ( )
  9. {
  10. console.log ( '[Info/cluster] process restarted' );
  11. cluster.fork ( );
  12. }, 8500 );
  13. } );
  14. }
  15. else
  16. {
  17. require ( './index.js' );
  18. }