node/test/parallel/test-cluster-rr-domain-listen.js
Gibson Fahnestock 7a0e462f9f test: use eslint to fix var->const/let
Manually fix issues that eslint --fix couldn't do automatically.

PR-URL: https://github.com/nodejs/node/pull/10685
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2017-01-11 11:43:52 +00:00

31 lines
699 B
JavaScript

'use strict';
const common = require('../common');
const cluster = require('cluster');
const domain = require('domain');
// RR is the default for v0.11.9+ so the following line is redundant:
// cluster.schedulingPolicy = cluster.SCHED_RR;
if (cluster.isWorker) {
const d = domain.create();
d.run(function() { });
const http = require('http');
http.Server(function() { }).listen(common.PORT, '127.0.0.1');
} else if (cluster.isMaster) {
//Kill worker when listening
cluster.on('listening', function() {
worker.kill();
});
//Kill process when worker is killed
cluster.on('exit', function() {
process.exit(0);
});
//Create worker
const worker = cluster.fork();
}