diff options
author | Sameer Srivastava <sameer13@gmail.com> | 2018-03-06 11:57:49 +0300 |
---|---|---|
committer | Richard Lau <riclau@uk.ibm.com> | 2018-03-21 22:27:54 +0300 |
commit | 9b34ea6161a637d6be7a68b816df8f8479d7c4ee (patch) | |
tree | 8d72900a0022253fcf5cd13f6d946555621cc034 /lib/internal/cluster | |
parent | 6a9f0499688b7515f3156a1754583d7624b25989 (diff) |
cluster: add support for NODE_OPTIONS="--inspect"
When using cluster and --inspect as cli argument it is correctly
handled and each worker will use a different port, this was
fixed by #13619. But when env var NODE_OPTIONS="--inspect"
is set this logic doesn't apply and the workers will fail as they
try to attach to the same port.
Fixes: https://github.com/nodejs/node/issues/19026
PR-URL: https://github.com/nodejs/node/pull/19165
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'lib/internal/cluster')
-rw-r--r-- | lib/internal/cluster/master.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/internal/cluster/master.js b/lib/internal/cluster/master.js index 7ee43689c4c..8e4f9395da6 100644 --- a/lib/internal/cluster/master.js +++ b/lib/internal/cluster/master.js @@ -103,11 +103,14 @@ function createWorkerProcess(id, env) { const workerEnv = util._extend({}, process.env); const execArgv = cluster.settings.execArgv.slice(); const debugArgRegex = /--inspect(?:-brk|-port)?|--debug-port/; + const nodeOptions = process.env.NODE_OPTIONS ? + process.env.NODE_OPTIONS : ''; util._extend(workerEnv, env); workerEnv.NODE_UNIQUE_ID = '' + id; - if (execArgv.some((arg) => arg.match(debugArgRegex))) { + if (execArgv.some((arg) => arg.match(debugArgRegex)) || + nodeOptions.match(debugArgRegex)) { let inspectPort; if ('inspectPort' in cluster.settings) { if (typeof cluster.settings.inspectPort === 'function') |