blob: 64b338cd8ab836745346ea85cdb5e12929356e47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
'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));
}
}
|