{"_id":"@almonds/http-shutdown","_rev":"3-948acd9c0bc603a989e5d01dcc347df3","name":"@almonds/http-shutdown","dist-tags":{"latest":"1.2.1-rc.2"},"versions":{"1.2.1-rc.0":{"name":"@almonds/http-shutdown","version":"1.2.1-rc.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":"ae57b674df24a31cd4f6b95c47992eb7ae619cb8","bugs":{"url":"https://github.com/thedillonb/http-shutdown/issues"},"homepage":"https://github.com/thedillonb/http-shutdown#readme","_id":"@almonds/http-shutdown@1.2.1-rc.0","_nodeVersion":"11.10.0","_npmVersion":"6.7.0","dist":{"integrity":"sha512-Pj7J177lmeGJfU1icAjc1PPThBM6Ch+hzLIssWg3rY2kKSOXiWDMf1/Ec+Rjza7pY9aV1JgKjjYCnaf+pYNouw==","shasum":"fc41343f5d54d4b5cf7168a8ef5d06b5900cd8e2","tarball":"https://registry.npmjs.org/@almonds/http-shutdown/-/http-shutdown-1.2.1-rc.0.tgz","fileCount":8,"unpackedSize":9167,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc5A/1CRA9TVsSAnZWagAAbOsP/RbORLQ6vA9O9uVsTI4L\n2AbArNkCEu8mTZsJHwnxYzwmZlnE8+cMQeHeQXiRoUK4OIhadmACeKaBGYAm\n/k34Yl8LTtsR4SZBI3IqbVznOJpoXUEeH1PMZHpw0WfWTAhADKQECumyX+bA\n4xi8MOr8cDeM2NcnD5sjTYgwGmebSBlFc21tjkZ3Y4aEbKPYWmRSnG0GLPT2\nlgoscRtw6tf4ur3Lo7HMsFvb8xqNReM90Ow2BtEbTwFdzp8xErnovhkiIxXi\nT44ad1mstLPhNu7mtRRJ5+MfOdri6Rr0y0IpaXerI7Zkaac52oDHEeptgcep\nqmtSpJ6IEPli0C4V/6JBPkbX00vMNSEaawP9dgf+46vzTUrQrjZayBERJ3Ze\nElhNUk9A/8J2mZHBNxfE2SEQVCekCCx0uf7bo9W0U9wKJnfUltKMhIpLL7X7\najmAxXe3XYNMogW9a2a7V8Rt4yrlWQeqLLTs6U0faRk0YcI+jg/zSm0PGxKX\nwbbKCll3BIV5wUltgLxJGQbU9WbmjcU1HhDqx2kZ7L6CGwB5kMkdsfyseKsy\nRTZ6EL42m7TBOOSAwMsRIf/92AgYinsPotBFtBwXHoL/1YKj4Q4ivSjTM5M5\nb6rWEYSj9J7MF3pGN9/MwEcpuOru2L6v2gkt8UxOatvgJzS6bWaxeyeoEumB\nTPpY\r\n=V8Cw\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICBbyStfEgDiUKgqcQMiWcihBWDsHbW+uxGMTNjuhRxZAiAW+4qfpw37+jP6+apxjX7WlCkIbEo8j0UX/gS5w1JSZQ=="}]},"maintainers":[{"name":"almonds","email":"ariel.shaqed@gmail.com"}],"_npmUser":{"name":"almonds","email":"ariel.shaqed@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/http-shutdown_1.2.1-rc.0_1558450164443_0.8500543715852118"},"_hasShrinkwrap":false},"1.2.1-rc.1":{"name":"@almonds/http-shutdown","version":"1.2.1-rc.1","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":"ae57b674df24a31cd4f6b95c47992eb7ae619cb8","bugs":{"url":"https://github.com/thedillonb/http-shutdown/issues"},"homepage":"https://github.com/thedillonb/http-shutdown#readme","_id":"@almonds/http-shutdown@1.2.1-rc.1","_nodeVersion":"11.10.0","_npmVersion":"6.7.0","dist":{"integrity":"sha512-yCMVFIhWfNdWoPmLJFnNWF2WDl+OaxdrqLtLp8BZ61G0S7LeLjzVVMjYwem33BlOETOTDnlwEcMCOzgPj+ltBQ==","shasum":"bd3e66d777f0c675bb02eaf5e976365dab408ca1","tarball":"https://registry.npmjs.org/@almonds/http-shutdown/-/http-shutdown-1.2.1-rc.1.tgz","fileCount":8,"unpackedSize":9168,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc5BHvCRA9TVsSAnZWagAAj8UP/3TuqJiXzSjY9e8j7lh6\nPAuEp9kRw5Z09FEJ5msVYTuBNXoKvR50vAbc3EZGsFgDHjINksTdYvP+RRIk\nHlnZ3nzVc976fTWvSv8pMy48JaiXuCI6b0P9i863eBxZmOtRmB42XKEXyouj\n+iEx/KQWYfnZxzvc3tH+mneqJJRXaeRp6UX0FVkgZUGgyS4V/QXvqEJy5UEb\n78VVEOS+raQ6I0vmPfvBQjkkPiUGYX0ZHWpla8is/zBHG29M4/mLqX18bR2b\ndSNZ3uvls54XDP1jmp3xmHLApmyHmBHLj06JN5m4cSDGFUQYg5x8cc3wQrnS\nn1sLpwbVfAAFTKbffE/iJCPZpXKff7k4Sz5wDEdU0JPRxIWdi7UyIyFFROiu\nx4XdTgt8zKGJ/dKkrqksSHKtOkk41QG+JJGBvcFi8f4YemRm1AQ/kNw9leOe\nLc0tTaCwAjWFFwnP4CNgLuYRwossm6/uzM8F44pLxz225Fv6wrRAmbs0D8L3\nRCXdhuYiwNMxtCL+Un/Gw/dZmgjjOB6ZBGx7GcPrLjrXQH0TbV3PGpsbgMs/\nusfh9rVDVHN1l4HQM5doi+ve6ykA/eF6LLZ1f9ePnHdsiwiA7RAtMwX2B80j\nEcJl3exlSiqedYePM0Xol/gSqOWJf6bLhbDiSySiWpOd1VKK/U3eyFLHPquH\nf3WM\r\n=iKQQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDuTTyzyLz64Qvz9rfy+5/J3vv31zcaPKYA5wV7iYTEGgIhAMjGrcH5VJHWyCwBk3fipROyZUwEk+eYc0t3Ipa5UAQ4"}]},"maintainers":[{"name":"almonds","email":"ariel.shaqed@gmail.com"}],"_npmUser":{"name":"almonds","email":"ariel.shaqed@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/http-shutdown_1.2.1-rc.1_1558450671125_0.8259626200449071"},"_hasShrinkwrap":false},"1.2.1-rc.2":{"name":"@almonds/http-shutdown","version":"1.2.1-rc.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","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":"ae57b674df24a31cd4f6b95c47992eb7ae619cb8","bugs":{"url":"https://github.com/thedillonb/http-shutdown/issues"},"homepage":"https://github.com/thedillonb/http-shutdown#readme","_id":"@almonds/http-shutdown@1.2.1-rc.2","_nodeVersion":"11.10.0","_npmVersion":"6.7.0","dist":{"integrity":"sha512-hwJWUj2tUWS7nFcA5Ha3YCcgpTWv8D67uWQSkfQrlxzKuFwm91U9Mtf/ywcYNFpftIZ/tMBsW4Vf0QGf/uzCVQ==","shasum":"feb30fb6dbce437ad4f2f7555ccc008d849c4ffd","tarball":"https://registry.npmjs.org/@almonds/http-shutdown/-/http-shutdown-1.2.1-rc.2.tgz","fileCount":8,"unpackedSize":9327,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc5BNACRA9TVsSAnZWagAA7wQP/0AxeTFnGk4gsoHEuayH\nMPiBBO1eeqtqkkrWrgSMvJHqP8KteL4IfFz/5wp6xGVnjS0ZneKz9dQxJWsa\nKZN9NtgG+Vgt0peB8VlLzN+YxzESCC/AGwWqxBI3+Heq7vsUJPPDHxbdMADy\npc57BUdWYgnvJZvTCSM9Kh31jM6dSjj/N3rmeO5m6/TR/+Bx2sfecjN5sC9X\nEy42MTJdext1wdxMRs3T3rI4EWdOWe1xWhAgnwhx04EkzXzcR8Nwdpn69hpj\nfY/4E4mByviBDlMT21BzWh9NcXKnpyAssIPXuaoQLUj854j/zFvedEpw1V+1\noVxo8lkgPxVHm+YQFcccU5VgqcV0bNyrY5DyhrMYW8kIILaQueKocAntxPaC\n5H3xMhwDjmQvCGjHRdLwc5XPnjJBl4Z9UFoGbUjvC/091IdzcfzOyYcj/9yh\n8yAlxuhKuP5ZIpKGtKqi1CRlUtJH96dYIMXdC8QcLpa1PpP28bFOw9RmctZx\nCkHlEfKoUW++eBm83mXkQTXDugktAgePROv2mLmBVmS06e1a130RAZOdAOqv\n9X5joa0teCK9S6TkngLGnQzHZGwbjYgXyGWbTEZqkJ/awAx5Er9CSjADqtmj\nZsb36kjh3XacLpMiGZmQ4MjG7eI1MqwdSyjub2mQ6DBr5IC96VXThMusbas1\ntDAK\r\n=2yXm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD0/7jBKm7wJNKhQuv+0te8BAMixKK2pOxv437XXNxz8wIhAIWUdNa+Itpv2O2ipKNHHGhxbBH2n2ClNNBY3bopnx6i"}]},"maintainers":[{"name":"almonds","email":"ariel.shaqed@gmail.com"}],"_npmUser":{"name":"almonds","email":"ariel.shaqed@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/http-shutdown_1.2.1-rc.2_1558451007536_0.7084445097272707"},"_hasShrinkwrap":false}},"time":{"created":"2019-05-21T14:49:24.396Z","1.2.1-rc.0":"2019-05-21T14:49:24.621Z","modified":"2022-04-04T13:36:41.063Z","1.2.1-rc.1":"2019-05-21T14:57:51.228Z","1.2.1-rc.2":"2019-05-21T15:03:27.654Z"},"maintainers":[{"name":"almonds","email":"ariel.shaqed@gmail.com"}],"description":"Gracefully shutdown a running HTTP server.","homepage":"https://github.com/thedillonb/http-shutdown#readme","keywords":["http","https","graceful","force","shutdown"],"repository":{"type":"git","url":"git+https://github.com/thedillonb/http-shutdown.git"},"author":{"name":"Dillon Buchanan"},"bugs":{"url":"https://github.com/thedillonb/http-shutdown/issues"},"license":"MIT","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() {\n  console.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() {\n  console.log('Everything is cleanly shutdown.');\n});\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","readmeFilename":"readme.md"}