Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable restarting in PM2

Tags:

node.js

pm2

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.

like image 843
kamesh Avatar asked Dec 15 '15 16:12

kamesh


People also ask

Does pm2 auto restart?

PM2 will keep your application forever alive, auto-restarting across crashes and machine restarts.

What is PID in pm2?

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 .

What is watching in pm2?

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.


1 Answers

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
like image 143
Cels Avatar answered Sep 25 '22 13:09

Cels