php调用shell 重启 forever nodejs
2014-03-26 16:30 freefei 阅读(524) 评论(0) 收藏 举报折腾了两天
搞定定
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
浙公网安备 33010602011771号