Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the pm2 node module restarts the app after crash automatically

Tags:

node.js

pm2

I have a Node.js app ready which is workable, but has known and unknown bugs which crash the app. In such cases it would be nice if pm2 can restart the node app. Is this feature already available in pm2?

like image 408
Talespin_Kit Avatar asked Oct 01 '14 06:10

Talespin_Kit


People also ask

Does pm2 auto restart on crash?

When starting application with PM2, application are automatically restarted on auto exit, event loop empty (node. js) or when application crash. But you can also configure extra restart strategies like: Restart app at a specified CRON time.

Does pm2 auto restart after reboot?

The start script sets up PM2 as a service under the init system. When the server restarts, it will automatically restart PM2, which will then restart all the Node. js applications/processes it is managing. In this article, we will show you how to deploy PM2 as a service to reliably manage your Node.

Does node require restart?

This is a quick tip for using nodemon to monitor your JavaScript files for any change. While doing development on any NodeJS application, whenever we make any change to some file we need to restart our Node server from the command prompt/terminal.


1 Answers

Yes, it does this by default. For more information see Restart strategies.

If the app repeatedly fails to start over a short period of time, pm2 may cease restarting. See configuration, min_uptime and max_restarts.

like image 144
jgillich Avatar answered Oct 08 '22 21:10

jgillich