Search code examples
node.jslinuxpm2

Does pm2 auto restart application after reboot by default?


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?


Solution

  • 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