diff --git a/lib/cluster.js b/lib/cluster.js index 4f8fb8c45e7..83dd3808594 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -214,13 +214,7 @@ function masterInit() { cluster.workers = {}; var intercom = new EventEmitter; - var settings = { - args: process.argv.slice(2), - exec: process.argv[1], - execArgv: process.execArgv, - silent: false - }; - cluster.settings = settings; + cluster.settings = {}; // XXX(bnoordhuis) Fold cluster.schedulingPolicy into cluster.settings? var schedulingPolicy = { @@ -247,6 +241,12 @@ function masterInit() { cluster.setupMaster = function(options) { if (initialized === true) return; initialized = true; + var settings = { + args: process.argv.slice(2), + exec: process.argv[1], + execArgv: process.execArgv, + silent: false + }; settings = util._extend(settings, options || {}); // Tell V8 to write profile data for each process to a separate file. // Without --logfile=v8-%p.log, everything ends up in a single, unusable @@ -282,10 +282,10 @@ function masterInit() { var workerEnv = util._extend({}, process.env); workerEnv = util._extend(workerEnv, env); workerEnv.NODE_UNIQUE_ID = '' + worker.id; - worker.process = fork(settings.exec, settings.args, { + worker.process = fork(cluster.settings.exec, cluster.settings.args, { env: workerEnv, - silent: settings.silent, - execArgv: createWorkerExecArgv(settings.execArgv, worker) + silent: cluster.settings.silent, + execArgv: createWorkerExecArgv(cluster.settings.execArgv, worker) }); worker.process.once('exit', function(exitCode, signalCode) { worker.suicide = !!worker.suicide;