mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 15:32:15 +00:00

* Move shared code into common * Favor use of strictEqual * Add some missing common.mustCalls * Other general cleanup PR-URL: https://github.com/nodejs/node/pull/8261 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
17 lines
580 B
JavaScript
17 lines
580 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const cluster = require('cluster');
|
|
|
|
if (cluster.isMaster) {
|
|
const worker = cluster.fork().on('online', common.mustCall(disconnect));
|
|
|
|
function disconnect() {
|
|
worker.disconnect();
|
|
// The worker remains in cluster.workers until both disconnect AND exit.
|
|
// Disconnect is supposed to disconnect all workers, but not workers that
|
|
// are already disconnected, since calling disconnect() on an already
|
|
// disconnected worker would error.
|
|
worker.on('disconnect', common.mustCall(cluster.disconnect));
|
|
}
|
|
}
|