|
@ -381,20 +381,18 @@ Worker.prototype.destroy = function() { |
|
|
this.suicide = true; |
|
|
this.suicide = true; |
|
|
|
|
|
|
|
|
if (cluster.isMaster) { |
|
|
if (cluster.isMaster) { |
|
|
// Stop channel
|
|
|
// Disconnect IPC channel
|
|
|
// this way the worker won't need to propagate suicide state to master
|
|
|
// this way the worker won't need to propagate suicide state to master
|
|
|
closeWorkerChannel(this, function() { |
|
|
closeWorkerChannel(this, function() { |
|
|
// Then kill worker
|
|
|
|
|
|
self.process.kill(); |
|
|
self.process.kill(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
// Channel is open
|
|
|
// Channel is open
|
|
|
if (this.process._channel !== null) { |
|
|
if (this.process.connected) { |
|
|
|
|
|
|
|
|
// Inform master that is is suicide and then kill
|
|
|
// Inform master that is is suicide and then kill
|
|
|
sendInternalMessage(this, {cmd: 'suicide'}, function() { |
|
|
sendInternalMessage(this, {cmd: 'suicide'}, function() { |
|
|
// Kill worker
|
|
|
|
|
|
process.exit(0); |
|
|
process.exit(0); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -404,7 +402,7 @@ Worker.prototype.destroy = function() { |
|
|
// from the master is resicved. Also we can't do a timeout and then
|
|
|
// from the master is resicved. Also we can't do a timeout and then
|
|
|
// just kill, since we don't know if the quickDestroy function was called.
|
|
|
// just kill, since we don't know if the quickDestroy function was called.
|
|
|
setInterval(function() { |
|
|
setInterval(function() { |
|
|
if (self.process._channel === null) { |
|
|
if (!self.process.connected) { |
|
|
process.exit(0); |
|
|
process.exit(0); |
|
|
} |
|
|
} |
|
|
}, 200); |
|
|
}, 200); |
|
@ -430,6 +428,7 @@ cluster.fork = function(env) { |
|
|
// However the workers may not die instantly
|
|
|
// However the workers may not die instantly
|
|
|
function quickDestroyCluster() { |
|
|
function quickDestroyCluster() { |
|
|
eachWorker(function(worker) { |
|
|
eachWorker(function(worker) { |
|
|
|
|
|
worker.process.disconnect(); |
|
|
worker.process.kill(); |
|
|
worker.process.kill(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|