blob: 985d15ce6475e6604344aabd8d34ab952030bc73 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
'use strict';
require('../common');
var cluster = require('cluster');
var assert = require('assert');
if (cluster.isMaster) {
var worker = cluster.fork();
assert.ok(worker.isConnected(),
'isConnected() should return true as soon as the worker has ' +
'been created.');
worker.on('disconnect', function() {
assert.ok(!worker.isConnected(),
'After a disconnect event has been emitted, ' +
'isConncted should return false');
});
worker.on('message', function(msg) {
if (msg === 'readyToDisconnect') {
worker.disconnect();
}
});
} else {
assert.ok(cluster.worker.isConnected(),
'isConnected() should return true from within a worker at all ' +
'times.');
cluster.worker.process.on('disconnect', function() {
assert.ok(!cluster.worker.isConnected(),
'isConnected() should return false from within a worker ' +
'after its underlying process has been disconnected from ' +
'the master');
});
process.send('readyToDisconnect');
}
|