summaryrefslogtreecommitdiff
path: root/lib/cluster.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2015-06-11 11:47:52 -0400
committerRod Vagg <rod@vagg.org>2015-08-04 11:56:12 -0700
commit423d8944ce58bc8c3f90d2827339a4dea10ab96e (patch)
treeb1d522f47ae02bac0bc9f70b9859acf6178682b7 /lib/cluster.js
parenteea66e2a7b34f10e723b5f3efa3efb2e2d30aafe (diff)
downloadandroid-node-v8-423d8944ce58bc8c3f90d2827339a4dea10ab96e.tar.gz
android-node-v8-423d8944ce58bc8c3f90d2827339a4dea10ab96e.tar.bz2
android-node-v8-423d8944ce58bc8c3f90d2827339a4dea10ab96e.zip
cluster: do not unconditionally set --debug-port
Currently, each cluster worker is assigned an ever increasing --debug-port argument. A long running cluster application that does not use the debugger can run into errors related to the port range. This commit mitigates the problem by only setting the debug port if the master is started with debug arguments, or the user explicitly defines debug arguments for the worker. This commit also adds a new debug port offset counter that is only incremented when a worker is created that utilizes debugging. Fixes: https://github.com/joyent/node/issues/8159 Refs: https://github.com/nodejs/io.js/pull/1524 PR-URL: https://github.com/nodejs/io.js/pull/1949 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Oleg Elifantiev <oleg@elifantiev.ru>
Diffstat (limited to 'lib/cluster.js')
-rw-r--r--lib/cluster.js10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/cluster.js b/lib/cluster.js
index 9f70c0273c..cbccd02605 100644
--- a/lib/cluster.js
+++ b/lib/cluster.js
@@ -278,11 +278,11 @@ function masterInit() {
cluster.emit('setup', settings);
}
+ var debugPortOffset = 1;
+
function createWorkerProcess(id, env) {
var workerEnv = util._extend({}, process.env);
var execArgv = cluster.settings.execArgv.slice();
- var debugPort = process.debugPort + id;
- var hasDebugArg = false;
workerEnv = util._extend(workerEnv, env);
workerEnv.NODE_UNIQUE_ID = '' + id;
@@ -291,14 +291,12 @@ function masterInit() {
var match = execArgv[i].match(/^(--debug|--debug-(brk|port))(=\d+)?$/);
if (match) {
+ let debugPort = process.debugPort + debugPortOffset;
+ ++debugPortOffset;
execArgv[i] = match[1] + '=' + debugPort;
- hasDebugArg = true;
}
}
- if (!hasDebugArg)
- execArgv = ['--debug-port=' + debugPort].concat(execArgv);
-
return fork(cluster.settings.exec, cluster.settings.args, {
env: workerEnv,
silent: cluster.settings.silent,