1.使用pm2启动node :# pm2 start /home/wwwroot/web.js --watch

2.dump这些进程列表:# pm2 save

3.生成自启动脚本:# pm2 startup centos

4.赋予权限:# chmod +x /etc/init.d/pm2-init.sh

5,添加服务:# chkconfig --add pm2-init.sh

通过这些步骤后,重启服务器,node.js是正常自启动了。这个时候再reboot,就发现以后都不能自启动了

解决方法:

# 启动项目
pm2 start /home/wwwroot/web.js
# 保存当前进程状态
pm2 save
# 生成开机自启动服务
pm2 startup
#开机服务
systemctl enable pm2-root
#重启
reboot

 

相关文章:

  • 2021-11-30
  • 2021-08-02
  • 2021-11-01
  • 2021-12-18
  • 2021-12-05
  • 2021-06-30
  • 2022-12-23
猜你喜欢
  • 2021-06-21
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-05
  • 2021-11-23
  • 2022-12-23
相关资源
相似解决方案