mirror of https://github.com/lukechilds/node.git
Browse Source
This commit causes Worker.prototype.disconnect() to send a suicide message to the cluster master. The function is also restructured to eliminate redundant code. Fixes: https://github.com/nodejs/node/issues/3238 PR-URL: https://github.com/nodejs/node/pull/3720 Reviewed-By: James M Snell <jasnell@gmail.com>v5.x
committed by
Jeremiah Senkpiel
2 changed files with 31 additions and 12 deletions
@ -0,0 +1,21 @@ |
|||||
|
'use strict'; |
||||
|
const common = require('../common'); |
||||
|
const assert = require('assert'); |
||||
|
const cluster = require('cluster'); |
||||
|
|
||||
|
if (cluster.isMaster) { |
||||
|
const worker = cluster.fork(); |
||||
|
let disconnected = false; |
||||
|
|
||||
|
worker.on('disconnect', common.mustCall(function() { |
||||
|
assert.strictEqual(worker.suicide, true); |
||||
|
disconnected = true; |
||||
|
})); |
||||
|
|
||||
|
worker.on('exit', common.mustCall(function() { |
||||
|
assert.strictEqual(worker.suicide, true); |
||||
|
assert.strictEqual(disconnected, true); |
||||
|
})); |
||||
|
} else { |
||||
|
cluster.worker.disconnect(); |
||||
|
} |
Loading…
Reference in new issue