summaryrefslogtreecommitdiff
path: root/lib/cluster.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2016-05-29 14:02:22 -0400
committercjihrig <cjihrig@gmail.com>2016-05-31 09:21:00 -0400
commitc4f80c1f3466eb56f33136ee6e2332335db0ec67 (patch)
tree276ad3fdb813f737d7ad42c07a2a2b324e5c82ab /lib/cluster.js
parent2369f89a035c00af1a17d89e53308612eb110af0 (diff)
downloadandroid-node-v8-c4f80c1f3466eb56f33136ee6e2332335db0ec67.tar.gz
android-node-v8-c4f80c1f3466eb56f33136ee6e2332335db0ec67.tar.bz2
android-node-v8-c4f80c1f3466eb56f33136ee6e2332335db0ec67.zip
cluster: rewrite debug ports consistently
When debug flags are passed to clustered applications, the debug port is rewritten for each worker process to avoid collisions. Prior to this commit, each debug flag would get a unique value. This commit reworks the logic to assign the same port value to all debug flags for a single worker. PR-URL: https://github.com/nodejs/node/pull/7050 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Diffstat (limited to 'lib/cluster.js')
-rw-r--r--lib/cluster.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/cluster.js b/lib/cluster.js
index a4b82ca1cc..45cbf5f772 100644
--- a/lib/cluster.js
+++ b/lib/cluster.js
@@ -299,6 +299,7 @@ function masterInit() {
function createWorkerProcess(id, env) {
var workerEnv = util._extend({}, process.env);
var execArgv = cluster.settings.execArgv.slice();
+ var debugPort = 0;
workerEnv = util._extend(workerEnv, env);
workerEnv.NODE_UNIQUE_ID = '' + id;
@@ -309,8 +310,11 @@ function masterInit() {
);
if (match) {
- const debugPort = process.debugPort + debugPortOffset;
- ++debugPortOffset;
+ if (debugPort === 0) {
+ debugPort = process.debugPort + debugPortOffset;
+ ++debugPortOffset;
+ }
+
execArgv[i] = match[1] + '=' + debugPort;
}
}