mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
675 B
27 lines
675 B
'use strict';
|
|
// test-cluster-worker-init.js
|
|
// verifies that, when a child process is forked, the cluster.worker
|
|
// object can receive messages as expected
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const cluster = require('cluster');
|
|
const msg = 'foo';
|
|
|
|
if (cluster.isMaster) {
|
|
const worker = cluster.fork();
|
|
|
|
worker.on('message', common.mustCall((message) => {
|
|
assert.strictEqual(message, true, 'did not receive expected message');
|
|
worker.disconnect();
|
|
}));
|
|
|
|
worker.on('online', () => {
|
|
worker.send(msg);
|
|
});
|
|
} else {
|
|
// GH #7998
|
|
cluster.worker.on('message', (message) => {
|
|
process.send(message === msg);
|
|
});
|
|
}
|
|
|