From 98deffd667c722732b65958456211db10e1fa34b Mon Sep 17 00:00:00 2001 From: Chris Breneman Date: Thu, 27 Mar 2014 10:26:18 -0400 Subject: [PATCH 1/3] Add option to specify time to wait before force-killing a worker --- cluster-master.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cluster-master.js b/cluster-master.js index 17894d9..5fd9720 100644 --- a/cluster-master.js +++ b/cluster-master.js @@ -296,10 +296,12 @@ function forkListener () { worker.on("disconnect", function () { debug("Worker %j disconnect", id) // give it 1 second to shut down gracefully, or kill - disconnectTimer = setTimeout(function () { - debug("Worker %j, forcefully killing", id) - worker.process.kill("SIGKILL") - }, 5000) + if(config.killWaitTime !== 0) { + disconnectTimer = setTimeout(function () { + debug("Worker %j, forcefully killing", id) + worker.process.kill("SIGKILL") + }, config.killWaitTime || 5000) + } }) }) } From 7b86cc39e5b7aebe485eacedb00235870ddc7e48 Mon Sep 17 00:00:00 2001 From: Ross Hadden Date: Wed, 30 Sep 2015 10:31:58 -0400 Subject: [PATCH 2/3] Removed a conditional. --- cluster-master.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cluster-master.js b/cluster-master.js index 5fd9720..8605aca 100644 --- a/cluster-master.js +++ b/cluster-master.js @@ -296,12 +296,10 @@ function forkListener () { worker.on("disconnect", function () { debug("Worker %j disconnect", id) // give it 1 second to shut down gracefully, or kill - if(config.killWaitTime !== 0) { - disconnectTimer = setTimeout(function () { - debug("Worker %j, forcefully killing", id) - worker.process.kill("SIGKILL") - }, config.killWaitTime || 5000) - } + disconnectTimer = setTimeout(function () { + debug("Worker %j, forcefully killing", id) + worker.process.kill("SIGKILL") + }, config.killWaitTime || 5000) }) }) } From 47a496eb733f2c00a444710033d25f4b1fb3ef55 Mon Sep 17 00:00:00 2001 From: Ross Hadden Date: Wed, 30 Sep 2015 10:35:34 -0400 Subject: [PATCH 3/3] Documented `killWaitTime` option. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8d3e2a8..36c4007 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ The `exec`, `env`, `argv`, and `silent` configs are passed to the * `onMessage` - Method that gets called when workers send a message to the parent. Called in the context of the worker, so you can reply by looking at `this`. +- `killWaitTime` - The time to wait before force-killing a worker. * `repl` - where to have REPL listen, defaults to `env.CLUSTER_MASTER_REPL` || 'cluster-master-socket' * if `repl` is null or false - REPL is disabled and will not be started * if `repl` is string path - REPL will listen on unix domain socket to this path