11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst cluster = require('cluster'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled(); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_cicheckForInspectSupport('--inspect'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_cifunction checkForInspectSupport(flag) { 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci const nodeOptions = JSON.stringify(flag); 131cb0ef41Sopenharmony_ci const numWorkers = 2; 141cb0ef41Sopenharmony_ci process.env.NODE_OPTIONS = flag; 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci if (cluster.isPrimary) { 171cb0ef41Sopenharmony_ci for (let i = 0; i < numWorkers; i++) { 181cb0ef41Sopenharmony_ci cluster.fork(); 191cb0ef41Sopenharmony_ci } 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci cluster.on('online', (worker) => { 221cb0ef41Sopenharmony_ci worker.disconnect(); 231cb0ef41Sopenharmony_ci }); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci cluster.on('exit', common.mustCall((worker, code, signal) => { 261cb0ef41Sopenharmony_ci const errMsg = `For NODE_OPTIONS ${nodeOptions}, failed to start cluster`; 271cb0ef41Sopenharmony_ci assert.strictEqual(worker.exitedAfterDisconnect, true, errMsg); 281cb0ef41Sopenharmony_ci }, numWorkers)); 291cb0ef41Sopenharmony_ci } 301cb0ef41Sopenharmony_ci} 31