0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-diagnostics-channel-process.js
theanarkh 0633e9a0b5
lib: add diagnostics channel for process and worker
PR-URL: https://github.com/nodejs/node/pull/44045
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-08-30 17:08:33 +00:00

22 lines
633 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const { ChildProcess } = require('child_process');
const dc = require('diagnostics_channel');
if (cluster.isPrimary) {
dc.subscribe('child_process', common.mustCall(({ process }) => {
assert.strictEqual(process instanceof ChildProcess, true);
}));
const worker = cluster.fork();
worker.on('online', common.mustCall(() => {
worker.send('disconnect');
}));
} else {
process.on('message', common.mustCall((msg) => {
assert.strictEqual(msg, 'disconnect');
process.disconnect();
}));
}