express-graceful-exit
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -0,1 +1,6 @@ | ||
0.4.1 / 2018-01-15 | ||
================== | ||
* Name anonymous functions for call stack clarity | ||
0.4.0 / 2017-03-19 | ||
@@ -2,0 +7,0 @@ ================== |
@@ -9,3 +9,3 @@ | ||
*/ | ||
exports.init = function (server) { | ||
exports.init = function init(server) { | ||
server.on('connection', function (socket) { | ||
@@ -20,3 +20,3 @@ sockets.push(socket); | ||
exports.gracefulExitHandler = function(app, server, _options) { | ||
exports.gracefulExitHandler = function gracefulExitHandler(app, server, _options) { | ||
// Get the options set up | ||
@@ -50,2 +50,3 @@ if (!_options) { | ||
options.callback(code); | ||
options.callback = false; // prevent 2nd call | ||
} else { | ||
@@ -57,3 +58,3 @@ logger("Registered callback is not a function"); | ||
// leave a bit of time to write logs, callback to complete, etc | ||
setTimeout(function() { | ||
setTimeout(function exitProcess() { | ||
process.exit(1); | ||
@@ -78,3 +79,3 @@ }, options.exitDelay); | ||
logger('All connections closed gracefully'); | ||
logger('No longer accepting connections'); | ||
exit(0); | ||
@@ -116,3 +117,3 @@ | ||
// be graceful, but failed. | ||
suicideTimeout = setTimeout(function() { | ||
suicideTimeout = setTimeout(function suicideHandler() { | ||
if (connectionsClosed) { | ||
@@ -140,5 +141,5 @@ // this condition should never occur, see server.close() above | ||
exports.middleware = function(app) { | ||
exports.middleware = function middleware(app) { | ||
// This flag is used to tell the middleware we create that the server wants | ||
// to stop, so we do not allow anymore connections. This is done for all new | ||
// to stop, so we do not allow any more connections. This is done for all new | ||
// connections for us by Node, but we need to handle the connections that are | ||
@@ -148,3 +149,3 @@ // using the Keep-Alive header to stay on. | ||
return function(req, res, next) { | ||
return function checkGracefulExit(req, res, next) { | ||
// Sorry Keep-Alive connections, but we need to part ways | ||
@@ -151,0 +152,0 @@ if (app.settings.graceful_exit === true) { |
{ | ||
"name": "express-graceful-exit", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Allow graceful exits for express apps, supporting zero downtime deploys", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12027
132