{"name":"graceful","version":"2.0.0","description":"Graceful exit when `uncaughtException` emit, base on `process.on('uncaughtException')`.","homepage":"https://github.com/node-modules/graceful","repository":{"type":"git","url":"git://github.com/node-modules/graceful.git"},"keywords":["graceful","uncaught","uncaughtException","error","graceful","cluster","graceful exit"],"author":{"name":"fengmk2","email":"fengmk2@gmail.com"},"license":"MIT","engines":{"node":">= 18.19.0"},"dependencies":{"@fengmk2/ps-tree":"^2.0.2","humanize-ms":"^2.0.0"},"devDependencies":{"@arethetypeswrong/cli":"^0.17.1","@eggjs/tsconfig":"1","@types/express":"^5.0.0","@types/mocha":"10","@types/node":"22","@types/supertest":"^6.0.2","egg-bin":"6","eslint":"8","eslint-config-egg":"14","express":"^4.21.2","mm":"^3.4.0","supertest":"^7.0.0","tshy":"3","tshy-after":"1","typescript":"5"},"scripts":{"lint":"eslint --cache src test --ext .ts","pretest":"npm run lint -- --fix && npm run prepublishOnly","test":"egg-bin test","preci":"npm run lint && npm run prepublishOnly && attw --pack","ci":"egg-bin cov","prepublishOnly":"tshy && tshy-after"},"type":"module","tshy":{"exports":{".":"./src/index.ts","./package.json":"./package.json"}},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./package.json":"./package.json"},"types":"./dist/commonjs/index.d.ts","main":"./dist/commonjs/index.js","module":"./dist/esm/index.js","_id":"graceful@2.0.0","gitHead":"f57c65a98aee474055bbf7e89eead057d2920031","bugs":{"url":"https://github.com/node-modules/graceful/issues"},"_nodeVersion":"18.20.5","_npmVersion":"10.8.2","dist":{"integrity":"sha512-q1SvWB1loG0xeZ2ZQBQC2m64RKmXmGjeNosFYKJrkDsQQI9rAgmXKSuaEqqTa90rJRShDnEG/MJDgqnFXI7Phw==","shasum":"9ac8ff00ce359c620dce05fed7bfda459daa58cc","tarball":"http://registry-npm.ywwl.com/graceful/download/graceful-2.0.0.tgz","fileCount":11,"unpackedSize":33953,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/graceful@2.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHPbcIgOhQpSKp8wHjm2GCivTcSlH0wt7AWgFpZQW1jRAiEAukZwhPLLgo5DPHoLHNCVYJzAE95UESMdQPauEpHNzdA="}],"size":7868,"noattachment":false,"key":"/graceful/-/graceful-2.0.0.tgz"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"directories":{},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/graceful_2.0.0_1734252306260_0.3313318092146669"},"_hasShrinkwrap":false,"readme":"# graceful\n\n[![NPM version][npm-image]][npm-url]\n[![Test coverage][cov-image]][cov-url]\n[![npm download][download-image]][download-url]\n[![Node.js Version](https://img.shields.io/node/v/graceful.svg?style=flat)](https://nodejs.org/en/download/)\n\n[npm-image]: https://img.shields.io/npm/v/graceful.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/graceful\n[cov-image]: https://codecov.io/github/node-modules/graceful/coverage.svg?branch=master\n[cov-url]: https://codecov.io/github/node-modules/graceful?branch=master\n[download-image]: https://img.shields.io/npm/dm/graceful.svg?style=flat-square\n[download-url]: https://npmjs.org/package/graceful\n\nGraceful exit when `uncaughtException` emit, base on `process.on('uncaughtException')`.\n\n## Why we should use this module\n\nIt's the best way to handle `uncaughtException` on current situations.\n\n* [Node.js 异步异常的处理与domain模块解析](http://deadhorse.me/nodejs/2013/04/13/exception_and_domain.html)\n\n## Install\n\n```bash\nnpm install graceful\n```\n\n## Usage\n\nPlease see [express_with_cluster](https://github.com/node-modules/graceful/tree/master/example/express_with_cluster) example.\n\nThis below code just for dev demo, don't use it on production env:\n\n```js\nconst express = require('express');\nconst { graceful } = require('graceful');\n\nconst app = express()\n.use()\n.use(function(req, res){\n  if (Math.random() > 0.5) {\n    foo.bar();\n  }\n  setTimeout(function() {\n    if (Math.random() > 0.5) {\n      throw new Error('Asynchronous error from timeout');\n    } else {\n      res.end('Hello from Connect!');\n    }\n  }, 100);\n  setTimeout(function() {\n    if (Math.random() > 0.5) {\n      throw new Error('Mock second error');\n    }\n  }, 200);\n})\n.use(function(err, req, res, next) {\n  res.end(err.message);\n});\n\nconst server = app.listen(1984);\n\ngraceful({\n  servers: [server],\n  killTimeout: '30s',\n});\n```\n\nIf you have multi servers on one process, you just add them to `server`:\n\n```js\ngraceful({\n  servers: [server1, server2, restapi],\n  killTimeout: '15s',\n});\n```\n\n### ESM and TypeScript\n\n```ts\nimport { graceful } from 'graceful';\n```\n\n## Contributors\n\n[![Contributors](https://contrib.rocks/image?repo=node-modules/graceful)](https://github.com/node-modules/graceful/graphs/contributors)\n\nMade with [contributors-img](https://contrib.rocks).\n\n## License\n\n[MIT](LICENSE)\n","publish_time":1734252306482,"_cnpm_publish_time":1734252306482,"dist-tags":{"latest":"2.0.0"}}