Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

252
Views
Why does pm2 fail to stop restarting?

I want my script to not automatically restart if there was an error. To only restart if it exited gracefully with exit code 0.

I created ecosystem.config.js in the script's folder and filled it with:

module.exports = {
  apps : [{
    name   : "My script",
    script : "./index.js",
    stop_exit_codes: [2]
  }]
}

So that when I use process.exit(2), it should stop the automatic restart.

However, it does not work and the script restarts automatically when I put this at the top of my script.

console.log("test");

process.exit(2);

So I tried using --stop-exit-codes instead:

pm2 start index.js --stop-exit-codes 2

But pm2 gives me this error:

error: unknown option --stop-exit-codes

How can I get the stop exit codes feature of PM2 to work?

Doc: https://pm2.keymetrics.io/docs/usage/restart-strategies/

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

module.exports = {

script:'api.js',

max_memory_restart:'30m'

}

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!