11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst cluster = require('cluster'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_cicluster.schedulingPolicy = cluster.SCHED_RR; 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciif (cluster.isPrimary) { 91cb0ef41Sopenharmony_ci const worker1 = cluster.fork(); 101cb0ef41Sopenharmony_ci worker1.on('listening', common.mustCall(() => { 111cb0ef41Sopenharmony_ci const worker2 = cluster.fork(); 121cb0ef41Sopenharmony_ci worker2.on('exit', (code, signal) => { 131cb0ef41Sopenharmony_ci assert.strictEqual( 141cb0ef41Sopenharmony_ci code, 151cb0ef41Sopenharmony_ci 0, 161cb0ef41Sopenharmony_ci `worker${worker2.id} did not exit normally. Exit with code: ${code}` 171cb0ef41Sopenharmony_ci ); 181cb0ef41Sopenharmony_ci assert.strictEqual( 191cb0ef41Sopenharmony_ci signal, 201cb0ef41Sopenharmony_ci null, 211cb0ef41Sopenharmony_ci `worker${worker2.id} did not exit normally. Exit with signal: ${signal}` 221cb0ef41Sopenharmony_ci ); 231cb0ef41Sopenharmony_ci worker1.disconnect(); 241cb0ef41Sopenharmony_ci }); 251cb0ef41Sopenharmony_ci })); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci worker1.on('exit', common.mustCall((code, signal) => { 281cb0ef41Sopenharmony_ci assert.strictEqual( 291cb0ef41Sopenharmony_ci code, 301cb0ef41Sopenharmony_ci 0, 311cb0ef41Sopenharmony_ci `worker${worker1.id} did not exit normally. Exit with code: ${code}` 321cb0ef41Sopenharmony_ci ); 331cb0ef41Sopenharmony_ci assert.strictEqual( 341cb0ef41Sopenharmony_ci signal, 351cb0ef41Sopenharmony_ci null, 361cb0ef41Sopenharmony_ci `worker${worker1.id} did not exit normally. Exit with code: ${signal}` 371cb0ef41Sopenharmony_ci ); 381cb0ef41Sopenharmony_ci })); 391cb0ef41Sopenharmony_ci} else { 401cb0ef41Sopenharmony_ci const net = require('net'); 411cb0ef41Sopenharmony_ci const server = net.createServer(); 421cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(() => { 431cb0ef41Sopenharmony_ci if (cluster.worker.id === 2) { 441cb0ef41Sopenharmony_ci server.close(() => { 451cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(() => { 461cb0ef41Sopenharmony_ci server.close(() => { 471cb0ef41Sopenharmony_ci process.disconnect(); 481cb0ef41Sopenharmony_ci }); 491cb0ef41Sopenharmony_ci })); 501cb0ef41Sopenharmony_ci }); 511cb0ef41Sopenharmony_ci } 521cb0ef41Sopenharmony_ci })); 531cb0ef41Sopenharmony_ci} 54