mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 23:16:28 +00:00
add sticky
This commit is contained in:
@@ -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`);
|
||||
// });
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user