使用pm2重新启动服务器时启动Node JS应用程序 [英] Start Node JS application when server reboots with pm2

查看:145
本文介绍了使用pm2重新启动服务器时启动Node JS应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次服务器启动时,我都试图使用模块pm2来启动我的node js应用程序. 我已经使用了命令pm2 startup ubuntu,但是每次我重新启动服务器时,我的应用程序都没有运行,因此必须再次手动启动它.

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?

推荐答案

请确保您确实保存了进程:

Make sure you do save your processes:

pm2 start app.js 
pm2 startup ubuntu 
pm2 save

一旦启动了应用程序,并希望它们在服务器重新启动时保持正常运行 做:pm2 save

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

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

这篇关于使用pm2重新启动服务器时启动Node JS应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆