File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11const log = require ( './src/log' ) ;
22const { setupApp } = require ( './src/app' ) ;
33const config = require ( 'config' ) ;
4- //const { createLightship } = require('lightship');
4+ const { createLightship } = require ( 'lightship' ) ;
5+ /**
6+ * Uses node cluster to make sure all CPU cores will be used
7+ * https://nodejs.org/api/cluster.html
8+ */
59const cluster = require ( 'cluster' ) ;
610const CPUs = require ( 'os' ) . cpus ( ) . length ;
711
8- log . info ( 'CPUs available' , CPUs ) ;
9-
10- //const ls = createLightship();
12+ /**
13+ * Lightship adds readiness and liveness prob endpoints
14+ * for kubernetes healthchecks https://github.com/gajus/lightship
15+ */
16+ const ls = createLightship ( ) ;
1117
1218if ( config . get ( 'App.cluster.enabled' ) && cluster . isMaster ) {
1319 log . info ( `Master ${ process . pid } is running` ) ;
1420
21+ // forks a process for each CPU core
1522 for ( let i = 0 ; i < CPUs ; i ++ ) {
1623 cluster . fork ( ) ;
1724 }
@@ -25,7 +32,7 @@ if(config.get('App.cluster.enabled') && cluster.isMaster) {
2532 log . info ( `Worker ${ process . pid } started` ) ;
2633 return app ;
2734 } )
28- // .then(() => ls.signalReady())
35+ . then ( ( ) => ls . signalReady ( ) )
2936 . catch ( error => {
3037 log . error ( error ) ;
3138 process . exit ( 1 ) ; // eslint-disable-line
Original file line number Diff line number Diff line change 2525 "elastic-apm-node" : " ^2.12.1" ,
2626 "express" : " ^4.17.1" ,
2727 "fibonacci" : " ^1.6.7" ,
28- "lightship" : " ^4.3.0 " ,
28+ "lightship" : " ^4.3.1 " ,
2929 "mongoose" : " ^4.13.19" ,
3030 "request" : " ^2.88.0" ,
3131 "request-promise" : " ^4.2.4" ,
You can’t perform that action at this time.
0 commit comments