Skip to content

Commit

Permalink
Stop running the forced shutdown timer when exiting.
Browse files Browse the repository at this point in the history
  • Loading branch information
ziggythehamster committed Jul 13, 2017
1 parent 1b95d11 commit 11b433f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/graceful-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ GracefulCluster.start = function(options) {

if (cluster.isMaster) {

var sigkill = false;
var currentRestartingPid = null;
var currentWorkersCount = 0;
var listeningWorkersCount = 0;
var restartQueue = [];
var currentRestartingPid = null;
var shutdownTimer = null;
var sigkill = false;

// Prevent killing all workers at same time when restarting.
function checkRestartQueue() {
Expand Down Expand Up @@ -95,6 +96,7 @@ GracefulCluster.start = function(options) {
function checkIfNoWorkersAndExit() {
if (!currentWorkersCount) {
log('Cluster graceful shutdown: done.');
if (shutdownTimer) clearTimeout(shutdownTimer);
exitFunction();
} else {
log('Cluster graceful shutdown: wait ' + currentWorkersCount + ' worker' + (currentWorkersCount > 1 ? 's' : '') + '.');
Expand All @@ -104,6 +106,7 @@ GracefulCluster.start = function(options) {
function startShutdown() {

if (disableGraceful) {
if (shutdownTimer) clearTimeout(shutdownTimer);
exitFunction();
return;
}
Expand All @@ -116,7 +119,7 @@ GracefulCluster.start = function(options) {
}

// Shutdown timeout.
setTimeout(function() {
shutdownTimer = setTimeout(function() {
log('Cluster graceful shutdown: timeout, force exit.');
exitFunction();
}, shutdownTimeout);
Expand Down

0 comments on commit 11b433f

Please sign in to comment.