折腾了两天

搞定定

forever 启动必须用root账户启动,

用php exce()函数去执行 shell 启动forever

exec('sudo -E -u root /usr/local/bin/node /usr/local/bin/forever start /nodeim/run.js');

  在计算机上

forever list 查看 已经启动了 但是nodejs.js 就是不运行 ,猜测是计算机上的forever 是 root权限启动

 

于是写了个 shell用 exec()去调用shell脚本

php

exec("sudo -E -u root /nodeim/restart.sh");

shell

#! /bin/bash
#script shell used init  config.js
#重启nodejs 的 forever



PATH=/usr/local/bin/node:/bin:/usr/bin:/sbin:/usr/sbin

export PATH=$PATH:/usr/local/bin/
#forever stopall&
#forever start  /nodeim/run.js
forever stopall
forever start /nodeim/run.js
exit 0

 

 

相关文章:

  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
  • 2021-09-05
  • 2022-12-23
  • 2021-08-07
猜你喜欢
  • 2022-12-23
  • 2021-10-27
  • 2021-05-25
  • 2021-05-30
相关资源
相似解决方案