2018-03-06 08:57:49 +00:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const cluster = require('cluster');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
common.skipIfInspectorDisabled();
|
|
|
|
|
|
|
|
checkForInspectSupport('--inspect');
|
|
|
|
|
|
|
|
function checkForInspectSupport(flag) {
|
|
|
|
|
|
|
|
const nodeOptions = JSON.stringify(flag);
|
|
|
|
const numWorkers = 2;
|
|
|
|
process.env.NODE_OPTIONS = flag;
|
|
|
|
|
2020-12-10 21:53:44 +00:00
|
|
|
if (cluster.isPrimary) {
|
2018-03-06 08:57:49 +00:00
|
|
|
for (let i = 0; i < numWorkers; i++) {
|
|
|
|
cluster.fork();
|
|
|
|
}
|
|
|
|
|
|
|
|
cluster.on('online', (worker) => {
|
|
|
|
worker.disconnect();
|
|
|
|
});
|
|
|
|
|
|
|
|
cluster.on('exit', common.mustCall((worker, code, signal) => {
|
|
|
|
const errMsg = `For NODE_OPTIONS ${nodeOptions}, failed to start cluster`;
|
|
|
|
assert.strictEqual(worker.exitedAfterDisconnect, true, errMsg);
|
|
|
|
}, numWorkers));
|
|
|
|
}
|
|
|
|
}
|