Skip to content

Commit

Permalink
cluster: restore v0.10.x setupMaster() behaviour
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rmg authored and trevnorris committed Jun 11, 2014
1 parent 61770f2 commit 4cd522d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4cd522d

Please sign in to comment.