0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-cluster-worker-isdead.js
Vse Mozhet Byt 88d2e699d8
test: remove unneeded string splitting
PR-URL: https://github.com/nodejs/node/pull/12992
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Luca Maraschi <luca.maraschi@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-05-15 13:49:45 +02:00

28 lines
710 B
JavaScript

'use strict';
require('../common');
const cluster = require('cluster');
const assert = require('assert');
if (cluster.isMaster) {
const worker = cluster.fork();
assert.ok(
!worker.isDead(),
'isDead() should return false right after the worker has been created.');
worker.on('exit', function() {
assert.ok(worker.isDead(),
'After an event has been emitted, isDead should return true');
});
worker.on('message', function(msg) {
if (msg === 'readyToDie') {
worker.kill();
}
});
} else if (cluster.isWorker) {
assert.ok(!cluster.worker.isDead(),
'isDead() should return false when called from within a worker');
process.send('readyToDie');
}