X0789
X0789

Reputation: 13

PM2 restart delay Node.js

I'm using this code in my own app:

pm2.restart('myapp', function() {});

Works fine, but how can I include delayed restart to that?

--restart-delay=3000

Upvotes: 1

Views: 1220

Answers (1)

felipekm
felipekm

Reputation: 2910

As mentioned in the API docs you should define this configuration "restartDelay" in your Start function, the restart only stop and start it again:

  pm2.start({
    name         : 'myapp',   // Script name
    script       : 'app.js',  // Script to be run
    exec_mode    : 'cluster', // Allows your app to be clustered
    restartDelay : 3000,      // Number of ms to wait before restarting the script
  }, function(err, apps) {
    pm2.disconnect();   // Disconnects from PM2
    if (err) throw err
  });

Upvotes: 1

Related Questions