fix: pass max-memory expose-gc as process args

This commit is contained in:
Barış Soner Uşaklı
2025-08-01 12:21:17 -04:00
parent de05dad251
commit d5f57af342

View File

@@ -99,8 +99,12 @@ Loader.start = function () {
function forkWorker(index, isPrimary) {
const ports = getPorts();
const args = [];
const execArgv = [];
if (nconf.get('max-memory')) {
args.push(`--max-old-space-size=${nconf.get('max-memory')}`);
execArgv.push(`--max-old-space-size=${nconf.get('max-memory')}`);
}
if (nconf.get('expose-gc')) {
execArgv.push('--expose-gc');
}
if (!ports[index]) {
return console.log(`[cluster] invalid port for worker : ${index} ports: ${ports.length}`);
@@ -109,10 +113,10 @@ function forkWorker(index, isPrimary) {
process.env.isPrimary = isPrimary;
process.env.isCluster = nconf.get('isCluster') || ports.length > 1;
process.env.port = ports[index];
const worker = fork(appPath, args, {
silent: silent,
env: process.env,
execArgv: execArgv,
});
worker.index = index;