Socket
Socket
Sign inDemoInstall

express-graceful-exit

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-graceful-exit - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

8

CHANGELOG.md

@@ -0,5 +1,11 @@

0.4.2 / 2018-09-30
==================
* Fix undefined socket array error
* Use intended exit code upon forced exit after timeout
0.4.1 / 2018-01-15
==================
* Name anonymous functions for call stack clarity
* Names for anonymous functions, for better stack traces

@@ -6,0 +12,0 @@ 0.4.0 / 2017-03-19

20

lib/graceful-exit.js

@@ -9,3 +9,3 @@

*/
exports.init = function init(server) {
exports.init = function (server) {
server.on('connection', function (socket) {

@@ -20,3 +20,3 @@ sockets.push(socket);

exports.gracefulExitHandler = function gracefulExitHandler(app, server, _options) {
exports.gracefulExitHandler = function(app, server, _options) {
// Get the options set up

@@ -50,3 +50,2 @@ if (!_options) {

options.callback(code);
options.callback = false; // prevent 2nd call
} else {

@@ -58,4 +57,4 @@ logger("Registered callback is not a function");

// leave a bit of time to write logs, callback to complete, etc
setTimeout(function exitProcess() {
process.exit(1);
setTimeout(function() {
process.exit(code);
}, options.exitDelay);

@@ -79,3 +78,3 @@ }

logger('No longer accepting connections');
logger('All connections closed gracefully');
exit(0);

@@ -117,3 +116,3 @@

// be graceful, but failed.
suicideTimeout = setTimeout(function suicideHandler() {
suicideTimeout = setTimeout(function() {
if (connectionsClosed) {

@@ -128,2 +127,3 @@ // this condition should never occur, see server.close() above

if (options.force) {
sockets = sockets || [];
logger('Destroying ' + sockets.length + ' open sockets');

@@ -142,5 +142,5 @@ sockets.forEach(function (socket) {

exports.middleware = function middleware(app) {
exports.middleware = function(app) {
// This flag is used to tell the middleware we create that the server wants
// to stop, so we do not allow any more connections. This is done for all new
// to stop, so we do not allow anymore connections. This is done for all new
// connections for us by Node, but we need to handle the connections that are

@@ -150,3 +150,3 @@ // using the Keep-Alive header to stay on.

return function checkGracefulExit(req, res, next) {
return function gracefulExitHandler(req, res, next) {
// Sorry Keep-Alive connections, but we need to part ways

@@ -153,0 +153,0 @@ if (app.settings.graceful_exit === true) {

{
"name": "express-graceful-exit",
"version": "0.4.1",
"version": "0.4.2",
"description": "Allow graceful exits for express apps, supporting zero downtime deploys",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc