allow passing of nodejs arguments to child process
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
Dec 12, 2025 at 13:33 UTC
131a7e11f0290f6905d1ca4163706a0a0160da76
1 file changed
+5
-10
meshcentral.js
+5
-10
@@ -594,13 +594,10 @@ function CreateMeshCentralServer(config, args) {
594
} else {
595
// if "--launch" is not specified, launch the server as a child process.
596
const startArgs = [];
597
- for (i in process.argv) {
598
- if (i > 0) {
599
- const arg = process.argv[i];
600
- if ((arg.length > 0) && ((arg.indexOf(' ') >= 0) || (arg.indexOf('&') >= 0))) { startArgs.push(arg); } else { startArgs.push(arg); }
601
- }
602
- }
603
- startArgs.push('--launch', process.pid);
597
+ for (const flag of process.execArgv) { startArgs.push(flag); }
598
+ startArgs.push(process.argv[1]);
599
+ for (let i = 2; i < process.argv.length; i++) { startArgs.push(process.argv[i]); }
600
+ startArgs.push('--launch', process.pid.toString());
601
obj.launchChildServer(startArgs);
602
}
603
};
@@ -610,9 +607,7 @@ function CreateMeshCentralServer(config, args) {
607
const child_process = require('child_process');
608
const isInspectorAttached = (()=> { try { return require('node:inspector').url() !== undefined; } catch (_) { return false; } }).call();
609
const logFromChildProcess = isInspectorAttached ? () => {} : console.log.bind(console);
613
- try { if (process.traceDeprecation === true) { startArgs.unshift('--trace-deprecation'); } } catch (ex) { }
614
- try { if (process.traceProcessWarnings === true) { startArgs.unshift('--trace-warnings'); } } catch (ex) { }
615
- if (startArgs[0] != "--disable-proto=delete") startArgs.unshift("--disable-proto=delete")
610
+ if (!startArgs.includes('--disable-proto=delete')) { startArgs.unshift('--disable-proto=delete'); }
611
childProcess = child_process.execFile(process.argv[0], startArgs, { maxBuffer: Infinity, cwd: obj.parentpath }, function (error, stdout, stderr) {
612
if (childProcess.xrestart == 1) {
613
setTimeout(function () { obj.launchChildServer(startArgs); }, 500); // This is an expected restart.