Start Node JS application when server reboots with pm2

北城余情 提交于 2019-12-20 02:35:22

问题


I am trying to use the module pm2 to start my node js app everytime the server boots. I have used the command pm2 startup ubuntu but each time I restart the server, my application is not running and I have to start it manually again.

Any ideas what is causing this issue?


回答1:


Make sure you do save your processes:

pm2 start app.js 
pm2 startup ubuntu 
pm2 save

Once you have started the apps and want to keep them on server reboot do: pm2 save

Source: https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#startup-script




回答2:


Go to your server directory and use the following commands:

pm2 start <your_app_name.js>
pm2 startup ubuntu
pm2 save


来源:https://stackoverflow.com/questions/32053549/start-node-js-application-when-server-reboots-with-pm2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!