mirror of
https://github.com/nodejs/node.git
synced 2024-11-28 22:46:31 +01:00
3e1b1dd4a9
The copyright and license notice is already in the LICENSE file. There is no justifiable reason to also require that it be included in every file, since the individual files are not individually distributed except as part of the entire package.
32 lines
742 B
JavaScript
32 lines
742 B
JavaScript
// test-cluster-worker-init.js
|
|
// verifies that, when a child process is forked, the cluster.worker
|
|
// object can receive messages as expected
|
|
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
var cluster = require('cluster');
|
|
var msg = 'foo';
|
|
|
|
if (cluster.isMaster) {
|
|
var worker = cluster.fork();
|
|
var timer = setTimeout(function() {
|
|
assert(false, 'message not received');
|
|
}, 5000);
|
|
|
|
timer.unref();
|
|
|
|
worker.on('message', function(message) {
|
|
assert(message, 'did not receive expected message');
|
|
worker.disconnect();
|
|
});
|
|
|
|
worker.on('online', function() {
|
|
worker.send(msg);
|
|
});
|
|
} else {
|
|
// GH #7998
|
|
cluster.worker.on('message', function(message) {
|
|
process.send(message === msg);
|
|
});
|
|
}
|