From 4cd522d15796ac558a2be8c623ed3fc1d7dfe3a0 Mon Sep 17 00:00:00 2001 From: Ryan Graham Date: Fri, 23 May 2014 12:41:40 -0700 Subject: [PATCH] cluster: restore v0.10.x setupMaster() behaviour In v0.10.x, process.argv and process.execArgv would only be evaluated and copied into cluster.settings on the first call to cluster.setupMaster() (either directly or via cluster.fork()), allowing them to be modified as needed before initializing the settings. In 41b75ca the behaviour was changed so that these values are initialized at the time of the first require('cluster'). Fixes #7670. Signed-off-by: Trevor Norris --- lib/cluster.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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;