diff options
author | Ryan Graham <r.m.graham@gmail.com> | 2014-05-22 18:56:18 -0700 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-07-15 00:12:43 +0400 |
commit | b96e38ac3a8b143a1129104569ff1b17acac1df4 (patch) | |
tree | 77b0e0245eababa6f589cd09215edc710e8c4fb1 /lib/cluster.js | |
parent | b69249376650251f24e90f81656ded1d10e8cae0 (diff) | |
download | android-node-v8-b96e38ac3a8b143a1129104569ff1b17acac1df4.tar.gz android-node-v8-b96e38ac3a8b143a1129104569ff1b17acac1df4.tar.bz2 android-node-v8-b96e38ac3a8b143a1129104569ff1b17acac1df4.zip |
cluster: allow multiple calls to setupMaster()
Only attributes of 'cluster.settings' will be modified after the first
call, leaving all other cluster initialization alone. Each call that
includes a 'settings' argument triggers a 'setup' event to be emitted.
Instead of each call resetting all values to their defaults, use the
current settings (if any) as the default. This retains setupMaster's
support how cluster.fork() uses setupMaster() to ensure
cluster.settings has been populated.
Update example in docs to use current node coding style and include
an example of progressive configuration.
Signed-off-by: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'lib/cluster.js')
-rw-r--r-- | lib/cluster.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/cluster.js b/lib/cluster.js index 269040ae01..e5d3533da3 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -239,14 +239,13 @@ function masterInit() { var initialized = false; 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, cluster.settings); 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 @@ -257,10 +256,15 @@ function masterInit() { { settings.execArgv = settings.execArgv.concat(['--logfile=v8-%p.log']); } + cluster.settings = settings; + if (initialized === true) + return options && process.nextTick(function() { + cluster.emit('setup'); + }); + initialized = true; schedulingPolicy = cluster.schedulingPolicy; // Freeze policy. assert(schedulingPolicy === SCHED_NONE || schedulingPolicy === SCHED_RR, 'Bad cluster.schedulingPolicy: ' + schedulingPolicy); - cluster.settings = settings; process.on('internalMessage', function(message) { if (message.cmd !== 'NODE_DEBUG_ENABLED') return; |