diff options
author | Miroslav Bajtoš <miro.bajtos@gmail.com> | 2013-05-02 08:34:22 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-05-08 16:53:52 -0700 |
commit | 43ec1b1c2e77d21c7571acd39860b9783aaf5175 (patch) | |
tree | 0a1ba5edab784e4f29f0b1f8fa1cdd3bf17b5f5d /test/fixtures/clustered-server | |
parent | 56492de5b9bcc6f34a39617b4687283c18f76693 (diff) | |
download | node-new-43ec1b1c2e77d21c7571acd39860b9783aaf5175.tar.gz |
debugger, cluster: each worker has new debug port
Implement support for debugging cluster workers. Each worker process
is assigned a new debug port in an increasing sequence.
I.e. when master process uses port 5858, then worker 1 uses port 5859,
worker 2 uses port 5860, and so on.
Introduce new command-line parameter '--debug-port=' which sets debug_port
but does not start debugger. This option works for all node processes, it
is not specific to cluster workers.
Fixes joyent/node#5318.
Diffstat (limited to 'test/fixtures/clustered-server')
-rw-r--r-- | test/fixtures/clustered-server/app.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/fixtures/clustered-server/app.js b/test/fixtures/clustered-server/app.js new file mode 100644 index 0000000000..16ebc69741 --- /dev/null +++ b/test/fixtures/clustered-server/app.js @@ -0,0 +1,25 @@ +var http = require('http'); +var cluster = require('cluster'); +var common = require('../../common.js'); + +function handleRequest(request, response) { + response.end('hello world\n'); +} + +var NUMBER_OF_WORKERS = 2; +var workersOnline = 0; + +if (cluster.isMaster) { + cluster.on('online', function() { + workersOnline++; + if (workersOnline == NUMBER_OF_WORKERS) + console.error('all workers are running'); + }); + + for (var i = 0; i < NUMBER_OF_WORKERS; i++) { + cluster.fork(); + } +} else { + var server = http.createServer(handleRequest); + server.listen(common.PORT+1000); +} |