Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

euthanasia

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

euthanasia

Gracefully exits a Node.js process when memory or CPU usage exceeds defined thresholds. Supports customizable exit logic via async hooks.

latest
Source
npmnpm
Version
2.0.1
Version published
Weekly downloads
1
-94.12%
Maintainers
2
Weekly downloads
 
Created
Source

euthanasia

when your node.js process uses too much memory or cpu, allow it to gracefully exit

usage:

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:

npm i euthanasia --save

license:

MIT

Keywords

nodejs

FAQs

Package last updated on 18 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts