Disable restarting in PM2

Simply --no-autorestart works like charm. Usage example : pm2 start script.js --no-autorestart


If you are using pm2 using config json file e.g pm2.config.json or whatever then need to specify similar option "autorestart" to false in your json file.

"autorestart" : false

E.g.

I am using pm2 to run a java application using below json config file

{
  "apps" : [
    {
      "name":"JAVA-Pm2",
      "cwd":".",
      "script":"/usr/bin/java",
      "args":[
        "-jar",
        "/dir/my-java-app/build/libs/my-java-app-all.jar"
    ],
    "node_args":[],
    "exec_interpreter":"",
    "exec_mode":"fork",
    "autorestart" : false
  } 
  ]
}

I think you need the --no-autorestart flag.

"do not automatically restart apps"

http://pm2.keymetrics.io/docs/usage/quick-start/


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

Tags:

Node.Js

Pm2