Skip to content

Commit 10c7e51

Browse files
committed
Update readmes and add lightship back
1 parent cf1bcb3 commit 10c7e51

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
const log = require('./src/log');
22
const { setupApp } = require('./src/app');
33
const 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+
*/
59
const cluster = require('cluster');
610
const 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

1218
if(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

package-lock.json

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
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",

0 commit comments

Comments
 (0)