1- /* eslint-disable no-console */
2-
31"use strict" ;
42
5- const
6- os = require ( "os" ) ,
3+ const os = require ( "os" ) ,
74 cluster = require ( "cluster" ) ,
85 stopSignals = [
9- "SIGHUP" , "SIGINT" , "SIGQUIT" , "SIGILL" , "SIGTRAP" , "SIGABRT" ,
10- "SIGBUS" , "SIGFPE" , "SIGUSR1" , "SIGSEGV" , "SIGUSR2" , "SIGTERM"
6+ "SIGHUP" ,
7+ "SIGINT" ,
8+ "SIGQUIT" ,
9+ "SIGILL" ,
10+ "SIGTRAP" ,
11+ "SIGABRT" ,
12+ "SIGBUS" ,
13+ "SIGFPE" ,
14+ "SIGUSR1" ,
15+ "SIGSEGV" ,
16+ "SIGUSR2" ,
17+ "SIGTERM"
1118 ] ,
1219 production = true ; //process.env.NODE_ENV == "production";
1320
1421let stopping = false ;
1522
16- cluster . on ( "disconnect" , function ( worker ) {
23+ cluster . on ( "disconnect" , function ( worker ) {
1724 if ( production ) {
1825 if ( ! stopping ) {
1926 cluster . fork ( ) ;
2027 }
21- } else
22- process . exit ( 1 ) ;
28+ } else process . exit ( 1 ) ;
2329} ) ;
2430
2531if ( cluster . isMaster ) {
@@ -30,11 +36,11 @@ if (cluster.isMaster) {
3036 }
3137
3238 if ( production ) {
33- stopSignals . forEach ( function ( signal ) {
34- process . on ( signal , function ( ) {
39+ stopSignals . forEach ( function ( signal ) {
40+ process . on ( signal , function ( ) {
3541 console . log ( `Got ${ signal } , stopping workers...` ) ;
3642 stopping = true ;
37- cluster . disconnect ( function ( ) {
43+ cluster . disconnect ( function ( ) {
3844 console . log ( "All workers stopped, exiting." ) ;
3945 process . exit ( 0 ) ;
4046 } ) ;
@@ -48,7 +54,6 @@ if (cluster.isMaster) {
4854 worker . process . argv . push ( hostname + "-worker-" + worker . id ) ;
4955
5056 require ( "./worker.js" ) ;
51-
5257}
5358
5459/**
0 commit comments