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
?
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.
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.
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.
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
.
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