mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 10:46:28 +00:00
Merge branch 'develop_v1.4.6'
This commit is contained in:
@@ -15,6 +15,8 @@ RUNNING_ON_MULTIPLE_PORT=NO
|
||||
# PISAHKAN DENGAN MENGGUNAKAN SEPARATOR KOMA TANPA SPASI
|
||||
PORTS=3001,3002,3003,3004
|
||||
|
||||
# ===================== CLUSTER NODE STICKY SESSION(YES or NO) ===========================
|
||||
CLUSTER_NODE_STICKY_SESSION=YES
|
||||
|
||||
# =========================== KONFIGURASI UNTUK SERVER ===========================
|
||||
# SERVER_FOR=development
|
||||
|
||||
@@ -5,7 +5,7 @@ const totalCPUs = require('node:os').cpus().length;
|
||||
const process = require('node:process');
|
||||
const winston = require('./application/helpers/winston.logger');
|
||||
const app = require('./server');
|
||||
// const sticky = require('sticky-session');
|
||||
const sticky = require('sticky-session');
|
||||
|
||||
var serverHSMStatus = 'HSM SERVER NOT CONNECTED';
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
@@ -60,20 +60,6 @@ function startExpress() {
|
||||
// set port, listen for requests
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
let message = `Server is running on version ${
|
||||
process.env.VERSION
|
||||
} environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `;
|
||||
|
||||
if (process.env.CLUSTER_NODE.toUpperCase() == 'YES') {
|
||||
message = `Server is running with cluster node on version ${
|
||||
process.env.VERSION
|
||||
} environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `;
|
||||
}
|
||||
|
||||
app.listen(PORT, () => {
|
||||
winston.logger.info(message);
|
||||
});
|
||||
|
||||
// jika settingan running on multiple
|
||||
if (
|
||||
process.env.RUNNING_ON_MULTIPLE_PORT.toUpperCase() == 'YES' &&
|
||||
@@ -107,18 +93,46 @@ function startExpress() {
|
||||
winston.logger.warn(
|
||||
`If you want running the service on multiple port, please set CLUSTER_NODE = NO in .env file `
|
||||
);
|
||||
} else if (
|
||||
process.env.CLUSTER_NODE_STICKY_SESSION.toUpperCase() == 'YES' &&
|
||||
process.env.CLUSTER_NODE.toUpperCase() == 'YES'
|
||||
) {
|
||||
winston.logger.warn(
|
||||
`If you want running the service with sticky session, please set CLUSTER_NODE = NO in .env file `
|
||||
);
|
||||
}
|
||||
|
||||
// const server = app.listen(PORT, () => {
|
||||
// console.log(
|
||||
// `Worker ${process.pid} started. Listening on port ${
|
||||
// server.address().port
|
||||
// }`
|
||||
// );
|
||||
// });
|
||||
let message = `Server is running on version ${
|
||||
process.env.VERSION
|
||||
} environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `;
|
||||
|
||||
// // Use sticky-session with the server instance
|
||||
// sticky.listen(server);
|
||||
if (process.env.CLUSTER_NODE.toUpperCase() == 'YES') {
|
||||
message = `Server is running with cluster node on version ${
|
||||
process.env.VERSION
|
||||
} environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `;
|
||||
} else if (process.env.CLUSTER_NODE_STICKY_SESSION.toUpperCase() == 'YES') {
|
||||
message = `Server is running with sticky session on version ${
|
||||
process.env.VERSION
|
||||
} environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `;
|
||||
}
|
||||
|
||||
if (process.env.CLUSTER_NODE_STICKY_SESSION.toUpperCase() == 'YES') {
|
||||
const server = app.listen(PORT, () => {
|
||||
console.log(
|
||||
`Worker ${process.pid} started. Listening on port ${
|
||||
server.address().port
|
||||
}`
|
||||
);
|
||||
winston.logger.info(message);
|
||||
});
|
||||
|
||||
// Use sticky-session with the server instance
|
||||
sticky.listen(server);
|
||||
} else {
|
||||
app.listen(PORT, () => {
|
||||
winston.logger.info(message);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Use sticky-session to handle sticky sessions
|
||||
|
||||
Reference in New Issue
Block a user