This commit is contained in:
2023-10-05 11:32:14 +07:00
parent b5061cf78e
commit b1814031b9
+13 -2
View File
@@ -1,9 +1,10 @@
require('dotenv').config();
var http = require('http');
const cluster = require('node:cluster');
const totalCPUs = require('node:os').cpus().length;
const process = require('node:process');
const winston = require('./application/helpers/winston.logger');
const server = require('./server');
const app = require('./server');
const sticky = require('sticky-session');
// set port, listen for requests
@@ -44,6 +45,7 @@ if (cluster.isMaster) {
cluster.on('exit', (worker, code, signal) => {
console.log(`worker ${worker.process.pid} died`);
console.log("Let's fork another worker!");
console.log('with code: ' + code);
cluster.fork();
});
} else {
@@ -56,11 +58,20 @@ if (cluster.isMaster) {
// startExpress();
function startExpress() {
sticky.listen(server, PORT, () => {
// var server = http.createServer(app);
// sticky.listen(server, PORT);
// winston.logger.info(
// `Server is running with sticky session on version ${
// process.env.VERSION
// } environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `
// );
// } else {
app.listen(PORT, () => {
winston.logger.info(
`Server is running on version ${
process.env.VERSION
} environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `
);
});
// }
}