mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
7a0e462f9f
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>
41 lines
870 B
JavaScript
41 lines
870 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const cluster = require('cluster');
|
|
const dgram = require('dgram');
|
|
|
|
if (common.isWindows) {
|
|
common.skip('dgram clustering is currently not supported ' +
|
|
'on windows.');
|
|
return;
|
|
}
|
|
|
|
if (cluster.isMaster) {
|
|
cluster.fork().on('exit', common.mustCall((code) => {
|
|
assert.strictEqual(code, 0);
|
|
}));
|
|
return;
|
|
}
|
|
|
|
const sockets = [];
|
|
function next() {
|
|
sockets.push(this);
|
|
if (sockets.length !== 2)
|
|
return;
|
|
|
|
// Work around health check issue
|
|
process.nextTick(() => {
|
|
for (let i = 0; i < sockets.length; i++)
|
|
sockets[i].close(close);
|
|
});
|
|
}
|
|
|
|
let waiting = 2;
|
|
function close() {
|
|
if (--waiting === 0)
|
|
cluster.worker.disconnect();
|
|
}
|
|
|
|
for (let i = 0; i < 2; i++)
|
|
dgram.createSocket({ type: 'udp4', reuseAddr: true }).bind(common.PORT, next);
|