add sticky

This commit is contained in:
2023-10-05 11:46:23 +07:00
parent b1814031b9
commit 74936dbe0d
+26 -10
View File
@@ -58,20 +58,36 @@ if (cluster.isMaster) {
// startExpress();
function startExpress() {
// var server = http.createServer(app);
// sticky.listen(server, PORT);
// app.listen(PORT, () => {
// winston.logger.info(
// `Server is running with sticky session on version ${
// `Server is running 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} `
// });
const server = app.listen(PORT, () => {
console.log(
`Worker ${process.pid} started. Listening on port ${
server.address().port
}`
);
});
// }
// Use sticky-session with the server instance
sticky.listen(server);
}
// Use sticky-session to handle sticky sessions
// if (!sticky.listen(cluster, port)) {
// // This is the master process, and it should not be listening to the port
// cluster.on('listening', (worker, address) => {
// console.log(
// `Worker ${worker.id} is now connected to ${address.address}:${address.port}`
// );
// });
// cluster.on('exit', (worker) => {
// console.log(`Worker ${worker.id} has exited`);
// });
// }