An open API service indexing awesome lists of open source software.

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

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