https://github.com/prozi/euthanasia
when your node.js process uses too much memory, allow it to gracefully exit
https://github.com/prozi/euthanasia
graceful-shutdown memory-management node-js oom out-of-memory
Last synced: 3 months ago
JSON representation
when your node.js process uses too much memory, allow it to gracefully exit
- Host: GitHub
- URL: https://github.com/prozi/euthanasia
- Owner: Prozi
- License: mit
- Created: 2023-07-01T21:08:17.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-20T10:58:26.000Z (about 1 year ago)
- Last Synced: 2025-02-28T05:53:22.274Z (8 months ago)
- Topics: graceful-shutdown, memory-management, node-js, oom, out-of-memory
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# euthanasia
when your node.js process uses too much memory or cpu, allow it to gracefully exit
## usage:
```js
const euthanasia = require('euthanasia');euthanasia({
memory: 100, // 100 MB limit
cpu: 80, // 80% CPU limit
interval: 10000, // check every 10 seconds
// called when either memory or CPU limit is exceeded
ready: async ({ memory, cpu }) => {
// your logic here
if (memory) {
console.log(`Memory limit exceeded: ${memory} MB`);
}
if (cpu) {
console.log(`CPU limit exceeded: ${cpu.toFixed(2)}%`);
}
// You can return false to skip exit (e.g., wait for cleanup)
return true;
}
});
```## install:
```bash
npm i euthanasia --save
```## license:
MIT