Skip to content

Releases: nenjack/euthanasia

Release list

v2.0.0

Choose a tag to compare

@nenjack nenjack released this 04 Jun 20:02
  • 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;
  }
});

v1.3.0

Choose a tag to compare

@nenjack nenjack released this 02 Jul 11:05
4eab442

ready stable version. it does what it should.

there is github workflow to run tests, they pass on last 3 LTS node versions printing a pretty

[OOM] Sorry but you used 4 MB

the ready function can but doesn't have to be async, and is optional, actually you can use something like

const euthanasia = require("euthanasia")

// check is memory usage > than 256 MB, every minute
euthanasia(256)

to achieve the same base example as in README

or you can

euthanasia(0, 1000, console.log)

to monitor your memory every second without quitting (console.log returns evaluates to false)