Skip to content

v2.0.0

Latest

Choose a tag to compare

@nenjack nenjack released this 04 Jun 20:02
· 3 commits to main since this release
  • feature: also now monitors cpu usage in % and allows exit of course also based on that
  • basically cpu and memory are optional so you can just omit either of them

breaking change

input to euthanasia() is now a single configuration JSON

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;
  }
});