I need to stop my nodejs app for some conditions.So I have used process.exit()
method. I am running my app with PM2. But PM2 is restarting the app whenever it was stopped. So is there any possibility to disable restarting in PM2.
PM2 will keep your application forever alive, auto-restarting across crashes and machine restarts.
The detailed process information listing contains data like . pid file location, app root path, out log and error log file paths, starting mode, uptime, interpreter, number restarts, etc. If you didn't choose a speaking app name, one of the most interesting parts in the process information output is the path .
PM2 can automatically restart your application when a file is modified in the current directory or its subdirectories: pm2 start app.js --watch. If --watch is enabled, stopping it won't stop watching: pm2 stop 0 will not stop watching.
If you are using the pm2 config file, use
"autorestart" : false
As suggested by @WitVault BUT make sure you don't have the watch
option set to true
like so:
"watch": true // This field should NOT be present, otherwise "autorestart" : false is ignored
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With