{"_id":"close-with-grace","_rev":"1927535","name":"close-with-grace","description":"Exit your process, gracefully (if possible)","dist-tags":{"latest":"1.1.0"},"maintainers":[{"name":"matteo.collina","email":""}],"time":{"modified":"2021-12-09T13:53:08.000Z","created":"2021-02-09T01:21:33.172Z","1.1.0":"2021-03-02T15:24:12.135Z","1.0.0":"2021-02-11T00:58:19.567Z","0.1.0":"2021-02-09T01:21:33.172Z"},"users":{},"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"repository":{"type":"git","url":"git+https://github.com/mcollina/close-with-grace.git"},"versions":{"1.1.0":{"name":"close-with-grace","version":"1.1.0","description":"Exit your process, gracefully (if possible)","main":"index.js","devDependencies":{"husky":"^4.3.8","standard":"^16.0.3","tap-dot":"^2.0.0","tape":"^5.1.1","tsd":"^0.14.0"},"scripts":{"test":"standard && tape test/*.test.js | tap-dot && tsd"},"husky":{"hooks":{"pre-commit":"npm test"}},"repository":{"type":"git","url":"git+https://github.com/mcollina/close-with-grace.git"},"keywords":["graceful","shutdown","close","exit"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/close-with-grace/issues"},"homepage":"https://github.com/mcollina/close-with-grace#readme","gitHead":"0fed246971658bd66ab89dcbc23e5992c9d7c1fa","_id":"close-with-grace@1.1.0","_nodeVersion":"14.15.4","_npmVersion":"7.6.0","dist":{"shasum":"91a48cf2019b5ae6e67b0255a32abcfd9bbca233","size":5039,"noattachment":false,"key":"/close-with-grace/-/close-with-grace-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/close-with-grace/download/close-with-grace-1.1.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/close-with-grace_1.1.0_1614698652003_0.8644900649690557"},"_hasShrinkwrap":false,"publish_time":1614698652135,"_cnpm_publish_time":1614698652135},"1.0.0":{"name":"close-with-grace","version":"1.0.0","description":"Exit your process, gracefully (if possible)","main":"index.js","devDependencies":{"husky":"^4.3.8","standard":"^16.0.3","tap-dot":"^2.0.0","tape":"^5.1.1"},"scripts":{"test":"standard && tape test/*.test.js | tap-dot"},"husky":{"hooks":{"pre-commit":"npm test"}},"repository":{"type":"git","url":"git+https://github.com/mcollina/close-with-grace.git"},"keywords":["graceful","shutdown","close","exit"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/close-with-grace/issues"},"homepage":"https://github.com/mcollina/close-with-grace#readme","gitHead":"6e570155ccf19ee97337173fb7511531d7e88142","_id":"close-with-grace@1.0.0","_nodeVersion":"14.15.4","_npmVersion":"7.5.2","dist":{"shasum":"b719c3c45aa1833b49e4418ac873d5664cd9421d","size":4059,"noattachment":false,"key":"/close-with-grace/-/close-with-grace-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/close-with-grace/download/close-with-grace-1.0.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/close-with-grace_1.0.0_1613005099409_0.48566936207286737"},"_hasShrinkwrap":false,"publish_time":1613005099567,"_cnpm_publish_time":1613005099567},"0.1.0":{"name":"close-with-grace","version":"0.1.0","description":"Exit your process, gracefully (if possible)","main":"index.js","devDependencies":{"husky":"^4.3.8","standard":"^16.0.3","tap-dot":"^2.0.0","tape":"^5.1.1"},"scripts":{"test":"standard && tape test/*.test.js | tap-dot"},"husky":{"hooks":{"pre-commit":"npm test"}},"repository":{"type":"git","url":"git+https://github.com/mcollina/close-with-grace.git"},"keywords":["graceful","shutdown","close","exit"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/close-with-grace/issues"},"homepage":"https://github.com/mcollina/close-with-grace#readme","gitHead":"167f93dd1c7a6ae69bd118f1ccc47c9827924966","_id":"close-with-grace@0.1.0","_nodeVersion":"14.15.4","_npmVersion":"7.5.2","dist":{"shasum":"9ea7b95104e1cd25fac217ee7ebe6fae8fb8cc52","size":3543,"noattachment":false,"key":"/close-with-grace/-/close-with-grace-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/close-with-grace/download/close-with-grace-0.1.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/close-with-grace_0.1.0_1612833692980_0.8770780942197569"},"_hasShrinkwrap":false,"publish_time":1612833693172,"_cnpm_publish_time":1612833693172}},"readme":"# close-with-grace\n\nExit your process, gracefully (if possible) - for Node.js\n\n## Install\n\n```\nnpm i close-with-grace\n```\n\n## Usage\n\n```js\nconst closeWithGrace = require('close-with-grace')\n\n// delay is the number of milliseconds for the graceful close to\n// finish.\ncloseWithGrace({ delay: 500 }, async function ({ signal, err, manual }) {\n  if (err) {\n    console.error(err)\n  }\n  await closeYourServer()\n})\n```\n\n## API\n\n### `closeWithGrace([opts], fn({ err, signal, manual }))`\n\n`closeWithGrace` adds a global listeners to the events:\n\n* `process.once('SIGTERM')`\n* `process.once('SIGINT')`\n* `process.once('uncaughtException')`\n* `process.once('unhandledRejection')`\n\nIn case one of them is emitted, it will call the given function.\nIf it is emitted again, it will terminate the process abruptly.\n\n#### opts\n\n* `delay`: the numbers of milliseconds before abruptly close the\n  process. Default: `10000`.\n\n#### fn({ err, signal, manual } [, cb])\n\nExecute the given function to perform a graceful close.\nThe function can either return a `Promise` or call the callback.\nIf this function does not error, the process will be closed with\nexit code `0`.\nIf the function rejects with an `Error`, or call the callback with an\n`Error` as first argument, the process will be closed with exit code\n`1`.\n\n#### return values\n\nCalling `closeWithGrace()` will return an object as formed:\n\n* `close()`: close the process, the `manual` argument will be set to\n  true.\n* `uninstall()`: remove all global listeners.\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/mcollina/close-with-grace#readme","bugs":{"url":"https://github.com/mcollina/close-with-grace/issues"},"license":"MIT"}