{"_id":"http-shutdown","_rev":"2887388","name":"http-shutdown","description":"Gracefully shutdown a running HTTP server.","dist-tags":{"latest":"1.2.2"},"maintainers":[{"name":"thedillonb","email":"thedillonb@gmail.com"}],"time":{"modified":"2022-11-04T06:14:02.000Z","created":"2015-11-25T06:43:52.583Z","1.2.2":"2020-01-10T13:29:18.976Z","1.2.1":"2019-05-29T18:54:59.855Z","1.2.0":"2017-02-28T04:52:29.657Z","1.1.0":"2016-09-19T13:55:29.506Z","1.0.3":"2015-11-30T23:05:49.651Z","1.0.2":"2015-11-30T22:53:18.042Z","1.0.1":"2015-11-25T07:03:07.259Z","1.0.0":"2015-11-25T06:43:52.583Z"},"users":{},"author":{"name":"Dillon Buchanan"},"repository":{"type":"git","url":"git+https://github.com/thedillonb/http-shutdown.git"},"versions":{"1.2.2":{"name":"http-shutdown","version":"1.2.2","description":"Gracefully shutdown a running HTTP server.","main":"index.js","types":"index.d.ts","scripts":{"test":"mocha","test-travis":"node --harmony node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["http","https","graceful","force","shutdown"],"author":{"name":"Dillon Buchanan"},"repository":{"type":"git","url":"git+https://github.com/thedillonb/http-shutdown.git"},"license":"MIT","devDependencies":{"@types/node":"^12.12.6","chai":"^3.4.1","istanbul":"^0.4.1","mocha":"^2.3.4","request":"^2.67.0"},"engines":{"iojs":">= 1.0.0","node":">= 0.12.0"},"gitHead":"4027e2d7f21317ee565f0bbe93205d9eb2ab5463","bugs":{"url":"https://github.com/thedillonb/http-shutdown/issues"},"homepage":"https://github.com/thedillonb/http-shutdown#readme","_id":"http-shutdown@1.2.2","_nodeVersion":"10.15.3","_npmVersion":"6.9.0","dist":{"shasum":"41bc78fc767637c4c95179bc492f312c0ae64c5f","size":4248,"noattachment":false,"key":"/http-shutdown/-/http-shutdown-1.2.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-shutdown/download/http-shutdown-1.2.2.tgz"},"maintainers":[{"name":"thedillonb","email":"thedillonb@gmail.com"}],"_npmUser":{"name":"thedillonb","email":"thedillonb@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/http-shutdown_1.2.2_1578662958841_0.814180390784478"},"_hasShrinkwrap":false,"publish_time":1578662958976,"_cnpm_publish_time":1578662958976,"_cnpmcore_publish_time":"2021-12-16T18:26:43.957Z"},"1.2.1":{"name":"http-shutdown","version":"1.2.1","description":"Gracefully shutdown a running HTTP server.","main":"index.js","types":"index.d.ts","scripts":{"test":"mocha","test-travis":"node --harmony node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["http","https","graceful","force","shutdown"],"author":{"name":"Dillon Buchanan"},"repository":{"type":"git","url":"git+https://github.com/thedillonb/http-shutdown.git"},"license":"MIT","devDependencies":{"chai":"^3.4.1","istanbul":"^0.4.1","mocha":"^2.3.4","request":"^2.67.0"},"engines":{"iojs":">= 1.0.0","node":">= 0.12.0"},"gitHead":"6eead0ca9e4e7ff29c1a3a12744e7eee0db1f4c1","bugs":{"url":"https://github.com/thedillonb/http-shutdown/issues"},"homepage":"https://github.com/thedillonb/http-shutdown#readme","_id":"http-shutdown@1.2.1","_nodeVersion":"10.15.3","_npmVersion":"6.9.0","dist":{"shasum":"f3be43af70d54c32c26ab7aa22d143d737ef761a","size":4187,"noattachment":false,"key":"/http-shutdown/-/http-shutdown-1.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-shutdown/download/http-shutdown-1.2.1.tgz"},"maintainers":[{"name":"thedillonb","email":"thedillonb@gmail.com"}],"_npmUser":{"name":"thedillonb","email":"thedillonb@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/http-shutdown_1.2.1_1559156099700_0.8491306019469733"},"_hasShrinkwrap":false,"publish_time":1559156099855,"_cnpm_publish_time":1559156099855,"_cnpmcore_publish_time":"2021-12-16T18:26:44.176Z"},"1.2.0":{"name":"http-shutdown","version":"1.2.0","description":"Gracefully shutdown a running HTTP server.","main":"index.js","scripts":{"test":"mocha","test-travis":"node --harmony node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["http","https","graceful","force","shutdown"],"author":{"name":"Dillon Buchanan"},"repository":{"type":"git","url":"git+https://github.com/thedillonb/http-shutdown.git"},"license":"MIT","devDependencies":{"chai":"^3.4.1","istanbul":"^0.4.1","mocha":"^2.3.4","request":"^2.67.0"},"engines":{"iojs":">= 1.0.0","node":">= 0.12.0"},"gitHead":"d543a1e5f96efeaffb219e55182b491bc0651f56","bugs":{"url":"https://github.com/thedillonb/http-shutdown/issues"},"homepage":"https://github.com/thedillonb/http-shutdown#readme","_id":"http-shutdown@1.2.0","_shasum":"df2d8067a8856e99d11e9dceb21609591e1df514","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"thedillonb","email":"thedillonb@gmail.com"},"dist":{"shasum":"df2d8067a8856e99d11e9dceb21609591e1df514","size":4077,"noattachment":false,"key":"/http-shutdown/-/http-shutdown-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-shutdown/download/http-shutdown-1.2.0.tgz"},"maintainers":[{"name":"thedillonb","email":"thedillonb@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/http-shutdown-1.2.0.tgz_1488257549106_0.16377176716923714"},"directories":{},"publish_time":1488257549657,"_hasShrinkwrap":false,"_cnpm_publish_time":1488257549657,"_cnpmcore_publish_time":"2021-12-16T18:26:44.394Z"},"1.1.0":{"name":"http-shutdown","version":"1.1.0","description":"Gracefully shutdown a running HTTP server.","main":"index.js","scripts":{"test":"mocha","test-travis":"node --harmony node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["http","https","graceful","force","shutdown"],"author":{"name":"Dillon Buchanan"},"repository":{"type":"git","url":"git+https://github.com/thedillonb/http-shutdown.git"},"license":"MIT","devDependencies":{"chai":"^3.4.1","istanbul":"^0.4.1","mocha":"^2.3.4","request":"^2.67.0"},"engines":{"iojs":">= 1.0.0","node":">= 0.12.0"},"gitHead":"c3eddbc4fc2da62db1b3fe727d375e5c7167d910","bugs":{"url":"https://github.com/thedillonb/http-shutdown/issues"},"homepage":"https://github.com/thedillonb/http-shutdown#readme","_id":"http-shutdown@1.1.0","_shasum":"83061dddfd0bd801e5f4fde2baab065b336ed1be","_from":".","_npmVersion":"2.15.1","_nodeVersion":"0.12.15","_npmUser":{"name":"thedillonb","email":"thedillonb@gmail.com"},"dist":{"shasum":"83061dddfd0bd801e5f4fde2baab065b336ed1be","size":3999,"noattachment":false,"key":"/http-shutdown/-/http-shutdown-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-shutdown/download/http-shutdown-1.1.0.tgz"},"maintainers":[{"name":"thedillonb","email":"thedillonb@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/http-shutdown-1.1.0.tgz_1474293327665_0.6318165939301252"},"directories":{},"publish_time":1474293329506,"_hasShrinkwrap":false,"_cnpm_publish_time":1474293329506,"_cnpmcore_publish_time":"2021-12-16T18:26:44.606Z"},"1.0.3":{"name":"http-shutdown","version":"1.0.3","description":"Gracefully shutdown a running HTTP server.","main":"index.js","scripts":{"test":"mocha","test-travis":"node --harmony node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["http","https","graceful","shutdown"],"author":{"name":"Dillon Buchanan"},"repository":{"type":"git","url":"git+https://github.com/thedillonb/http-shutdown.git"},"license":"MIT","devDependencies":{"chai":"^3.4.1","istanbul":"^0.4.1","mocha":"^2.3.4","request":"^2.67.0"},"engines":{"iojs":">= 1.0.0","node":">= 0.12.0"},"gitHead":"7056d7e4de4a3d8b7a8a17b00cf700ef81d15f2d","bugs":{"url":"https://github.com/thedillonb/http-shutdown/issues"},"homepage":"https://github.com/thedillonb/http-shutdown#readme","_id":"http-shutdown@1.0.3","_shasum":"d75bdb603a8a082ada6493ffa46d76b3a5d861e4","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.2","_npmUser":{"name":"thedillonb","email":"thedillonb@gmail.com"},"dist":{"shasum":"d75bdb603a8a082ada6493ffa46d76b3a5d861e4","size":3921,"noattachment":false,"key":"/http-shutdown/-/http-shutdown-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-shutdown/download/http-shutdown-1.0.3.tgz"},"maintainers":[{"name":"thedillonb","email":"thedillonb@gmail.com"}],"directories":{},"publish_time":1448924749651,"_hasShrinkwrap":false,"_cnpm_publish_time":1448924749651,"_cnpmcore_publish_time":"2021-12-16T18:26:44.793Z"},"1.0.2":{"name":"http-shutdown","version":"1.0.2","description":"Gracefully shutdown a running HTTP server.","main":"index.js","scripts":{"test":"mocha","test-travis":"node --harmony node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["http","https","graceful","shutdown"],"author":{"name":"Dillon Buchanan"},"repository":{"type":"git","url":"git+https://github.com/thedillonb/http-shutdown.git"},"license":"MIT","devDependencies":{"chai":"^3.4.1","istanbul":"^0.4.1","mocha":"^2.3.4","request":"^2.67.0"},"engines":{"iojs":">= 1.0.0","node":">= 0.12.0"},"gitHead":"12475b4f1a7bff47d0655594459fe94784d5e997","bugs":{"url":"https://github.com/thedillonb/http-shutdown/issues"},"homepage":"https://github.com/thedillonb/http-shutdown#readme","_id":"http-shutdown@1.0.2","_shasum":"1b4216a37a96f60e49c01d36fe7cbebbd83178dc","_from":".","_npmVersion":"2.14.9","_nodeVersion":"0.12.8","_npmUser":{"name":"thedillonb","email":"thedillonb@gmail.com"},"dist":{"shasum":"1b4216a37a96f60e49c01d36fe7cbebbd83178dc","size":3910,"noattachment":false,"key":"/http-shutdown/-/http-shutdown-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-shutdown/download/http-shutdown-1.0.2.tgz"},"maintainers":[{"name":"thedillonb","email":"thedillonb@gmail.com"}],"directories":{},"publish_time":1448923998042,"_hasShrinkwrap":false,"_cnpm_publish_time":1448923998042,"_cnpmcore_publish_time":"2021-12-16T18:26:44.997Z"},"1.0.1":{"name":"http-shutdown","version":"1.0.1","description":"Gracefully shutdown a running HTTP server.","main":"index.js","scripts":{"test":"mocha"},"keywords":["http","https","graceful","shutdown"],"author":{"name":"Dillon Buchanan"},"repository":{"type":"git","url":"git+https://github.com/thedillonb/http-shutdown.git"},"license":"MIT","devDependencies":{"chai":"^3.4.1","mocha":"^2.3.4","request":"^2.67.0"},"gitHead":"09c465f5ec73b991e1fc482ccc0e67be7c16c30f","bugs":{"url":"https://github.com/thedillonb/http-shutdown/issues"},"homepage":"https://github.com/thedillonb/http-shutdown#readme","_id":"http-shutdown@1.0.1","_shasum":"6fd5a6b9dad3743ca095d591d40295fa198f9b5a","_from":".","_npmVersion":"2.14.2","_nodeVersion":"4.0.0","_npmUser":{"name":"thedillonb","email":"thedillonb@gmail.com"},"dist":{"shasum":"6fd5a6b9dad3743ca095d591d40295fa198f9b5a","size":3193,"noattachment":false,"key":"/http-shutdown/-/http-shutdown-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-shutdown/download/http-shutdown-1.0.1.tgz"},"maintainers":[{"name":"thedillonb","email":"thedillonb@gmail.com"}],"directories":{},"publish_time":1448434987259,"_hasShrinkwrap":false,"_cnpm_publish_time":1448434987259,"_cnpmcore_publish_time":"2021-12-16T18:26:45.351Z"},"1.0.0":{"name":"http-shutdown","version":"1.0.0","description":"Gracefully shutdown a running HTTP server.","main":"index.js","scripts":{"test":"mocha"},"keywords":["http","https","graceful","shutdown"],"author":{"name":"Dillon Buchanan"},"license":"MIT","devDependencies":{"chai":"^3.4.1","mocha":"^2.3.4","request":"^2.67.0"},"gitHead":"81bfa635d7e5d3591237443ba9df6965cf49eeae","_id":"http-shutdown@1.0.0","_shasum":"1cb62d30db9cc632f5cb2c150f0a9101c52a825a","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.2","_npmUser":{"name":"thedillonb","email":"thedillonb@gmail.com"},"dist":{"shasum":"1cb62d30db9cc632f5cb2c150f0a9101c52a825a","size":2472,"noattachment":false,"key":"/http-shutdown/-/http-shutdown-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/http-shutdown/download/http-shutdown-1.0.0.tgz"},"maintainers":[{"name":"thedillonb","email":"thedillonb@gmail.com"}],"directories":{},"publish_time":1448433832583,"_hasShrinkwrap":false,"_cnpm_publish_time":1448433832583,"_cnpmcore_publish_time":"2021-12-16T18:26:45.571Z"}},"readme":"# Http-Shutdown [![NPM version][npm-image]][npm-url] [![Build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url]\nShutdown a Nodejs HTTP server gracefully by doing the following:\n\n1. Close the listening socket to prevent new connections\n2. Close all idle keep-alive sockets to prevent new requests during shutdown\n3. Wait for all in-flight requests to finish before closing their sockets.\n4. Profit!\n\nOther solutions might just use `server.close` which only terminates the listening socket and waits for other sockets to close - which is incomplete since keep-alive sockets can still make requests. Or, they may use `ref()/unref()` to simply cause Nodejs to terminate if the sockets are idle - which doesn't help if you have other things to shutdown after the server shutsdown.\n\n`http-shutdown` is a complete solution. It uses idle indicators combined with an active socket list to safely, and gracefully, close all sockets. It does not use `ref()/unref()` but, instead, actively closes connections as they finish meaning that socket 'close' events still work correctly since the sockets are actually closing - you're not just `unref`ing and forgetting about them.\n\n## Installation\n\n```bash\n$ npm install http-shutdown\n```\n\n## Usage\nThere are currently two ways to use this library. The first is explicit wrapping of the `Server` object:\n\n```javascript\n// Create the http server\nvar server = require('http').createServer(function(req, res) {\n  res.end('Good job!');\n});\n\n// Wrap the server object with additional functionality.\n// This should be done immediately after server construction, or before you start listening.\n// Additional functionailiy needs to be added for http server events to properly shutdown.\nserver = require('http-shutdown')(server);\n\n// Listen on a port and start taking requests.\nserver.listen(3000);\n\n// Sometime later... shutdown the server.\nserver.shutdown(function(err) {\n\tif (err) {\n\t\treturn console.log('shutdown failed', err.message);\n\t}\n\tconsole.log('Everything is cleanly shutdown.');\n});\n```\n\nThe second is implicitly adding prototype functionality to the `Server` object:\n\n```javascript\n// .extend adds a .withShutdown prototype method to the Server object\nrequire('http-shutdown').extend();\n\nvar server = require('http').createServer(function(req, res) {\n  res.end('God job!');\n}).withShutdown(); // <-- Easy to chain. Returns the Server object\n\n// Sometime later, shutdown the server.\nserver.shutdown(function(err) {\n\tif (err) {\n\t\treturn console.log('shutdown failed', err.message);\n\t}\n  console.log('Everything is cleanly shutdown.');\n});\n```\n\n## Test\n```bash\n$ npm test\n```\n\n[npm-image]: https://img.shields.io/npm/v/http-shutdown.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/http-shutdown\n[travis-image]: https://img.shields.io/travis/thedillonb/http-shutdown.svg?style=flat-square\n[travis-url]: https://travis-ci.org/thedillonb/http-shutdown\n[coveralls-image]: https://img.shields.io/coveralls/thedillonb/http-shutdown.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/thedillonb/http-shutdown\n","_attachments":{},"homepage":"https://github.com/thedillonb/http-shutdown#readme","bugs":{"url":"https://github.com/thedillonb/http-shutdown/issues"},"license":"MIT"}