diff options
author | Fedor Indutny <fedor@indutny.com> | 2014-10-04 18:44:46 +0400 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-10-08 15:36:13 +0400 |
commit | 3821863109be9e56f41f1ea6da0cb6e822037fc3 (patch) | |
tree | d15ee802716e8c2ced0a6b88eafc834154fa4c4d /lib/cluster.js | |
parent | 6a610a0f67f091092f1643326eaacb8c31f72259 (diff) | |
download | android-node-v8-3821863109be9e56f41f1ea6da0cb6e822037fc3.tar.gz android-node-v8-3821863109be9e56f41f1ea6da0cb6e822037fc3.tar.bz2 android-node-v8-3821863109be9e56f41f1ea6da0cb6e822037fc3.zip |
cluster: do not signal children in debug mode
Do not send signal to children if they are already in debug mode.
Node.js on Windows does not register signal handler, and thus calling
`process._debugProcess()` will throw an error.
Reviewed-By: Trevor Norris <trevnorris@gmail.com>
PR-URL: https://github.com/joyent/node/pull/8476
Diffstat (limited to 'lib/cluster.js')
-rw-r--r-- | lib/cluster.js | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/cluster.js b/lib/cluster.js index c994f433b9..6f355d0bc3 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -266,16 +266,34 @@ function masterInit() { assert(schedulingPolicy === SCHED_NONE || schedulingPolicy === SCHED_RR, 'Bad cluster.schedulingPolicy: ' + schedulingPolicy); - process.on('internalMessage', function(message) { - if (message.cmd !== 'NODE_DEBUG_ENABLED') return; - var key; - for (key in cluster.workers) - process._debugProcess(cluster.workers[key].process.pid); + var hasDebugArg = process.execArgv.some(function(argv) { + return /^(--debug|--debug-brk)(=\d+)?$/.test(argv); }); process.nextTick(function() { cluster.emit('setup', settings); }); + + // Send debug signal only if not started in debug mode, this helps a lot + // on windows, because RegisterDebugHandler is not called when node starts + // with --debug.* arg. + if (hasDebugArg) + return; + + process.on('internalMessage', function(message) { + if (message.cmd !== 'NODE_DEBUG_ENABLED') return; + var key; + for (key in cluster.workers) { + var worker = cluster.workers[key]; + if (worker.state === 'online') { + process._debugProcess(worker.process.pid); + } else { + worker.once('online', function() { + process._debugProcess(this.process.pid); + }); + } + } + }); }; function createWorkerProcess(id, env) { |