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/
请安装最新版本的库 pm2,在这里找到最新版本。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.