Skip to content

Commit

Permalink
Remove in-code clustering
Browse files Browse the repository at this point in the history
  • Loading branch information
Brayden Pellegrini committed May 3, 2021
1 parent d3f78df commit 93157cf
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions bin/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const cluster = require('cluster');
const numCPUs = require('os').cpus().length;
const {listen} = require('../app');
const logger = require('../app/log');

Expand All @@ -9,24 +7,9 @@ process.on('unhandledRejection', (reason, p) => {
process.exit(1);
});

if (cluster.isMaster) {
// Fork workers
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}

cluster.on('online', (worker) => {
logger.info(`Worker ${worker.process.pid} is online`);
});

cluster.on('exit', (worker, code, signal) => {
logger.info(`Worker ${worker.process.pid} died\nCode: ${code}\nSignal: ${signal}`);
// Start app
listen()
.catch((error) => {
logger.error(error);
process.exit(1);
});
} else {
// Start app
listen()
.catch((error) => {
logger.error(error);
process.exit(1);
});
}

0 comments on commit 93157cf

Please sign in to comment.