I have an issue with my linux server and need to reboot, before that I run my node application with pm2 start server.js
without any other config. Can it auto restart my app after reboot server?
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.
With reload, pm2 restarts all processes one by one, always keeping at least one process running. It also states that: If the reload system hasn't managed to reload your application, a timeout will fallback to a classic restart.
Not by default, but PM2 can do so using a startup script:
PM2 can generate startup scripts and configure them in order to keep your process list intact across expected or unexpected machine restarts.
After generating your startup script (read also this comment), take a look at pm2 save
:
Once you started all the applications you want to manage, you have to save the list you wanna respawn at machine reboot with:
pm2 save
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