mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
15164cebce
Doc deprecate isMaster and setupMaster in favor of isPrimary and setupPrimary. Signed-off-by: Michael Dawson <mdawson@devrus.com> PR-URL: https://github.com/nodejs/node/pull/36478 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com>
29 lines
794 B
JavaScript
29 lines
794 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
|
|
// Check that cluster works perfectly for both `kill` and `disconnect` cases.
|
|
// Also take into account that the `disconnect` event may be received after the
|
|
// `exit` event.
|
|
// https://github.com/nodejs/node/issues/3238
|
|
|
|
const assert = require('assert');
|
|
const cluster = require('cluster');
|
|
|
|
if (cluster.isPrimary) {
|
|
function forkWorker(action) {
|
|
const worker = cluster.fork({ action });
|
|
worker.on('disconnect', common.mustCall(() => {
|
|
assert.strictEqual(worker.exitedAfterDisconnect, true);
|
|
}));
|
|
|
|
worker.on('exit', common.mustCall(() => {
|
|
assert.strictEqual(worker.exitedAfterDisconnect, true);
|
|
}));
|
|
}
|
|
|
|
forkWorker('disconnect');
|
|
forkWorker('kill');
|
|
} else {
|
|
cluster.worker[process.env.action]();
|
|
}
|