/home/conan/nodejs/nodejs-forever/app.js:41
throw new Error('App is error from inner!');
^
Error: App is error from inner!
at null._onTimeout (/home/conan/nodejs/nodejs-forever/app.js:41:9)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
error: Forever detected script exited with code: 8
error: Forever restarting script for 3 time
Thu Sep 26 2013 16:15:33 GMT+0800 (CST)
Express server listening on port 3000
Thu Sep 26 2013 16:15:43 GMT+0800 (CST)
/home/conan/nodejs/nodejs-forever/app.js:41
throw new Error('App is error from inner!');
^
Error: App is error from inner!
at null._onTimeout (/home/conan/nodejs/nodejs-forever/app.js:41:9)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
error: Forever detected script exited with code: 8
error: Forever restarting script for 4 time
我们发现每10秒种,node内部挂掉,然后再被forever重启!!
通过list我们手动刷新几次也可以看到pid是变的。
复制代码 代码如下:
~ forever list
info: Forever processes running
data: uid command script forever pid logfile uptime
data: [0] SmtT /usr/local/bin/node app.js 18444 18579 logs/access.log 0:0:0:7.211
~ forever list
info: Forever processes running
data: uid command script forever pid logfile uptime
data: [0] SmtT /usr/local/bin/node app.js 18444 18579 logs/access.log 0:0:0:8.921
~ forever list
info: Forever processes running
data: uid command script forever pid logfile uptime
data: [0] SmtT /usr/local/bin/node app.js 18444 18604 logs/access.log 0:0:0:0.177
~ forever list
info: Forever processes running
data: uid command script forever pid logfile uptime
data: [0] SmtT /usr/local/bin/node app.js 18444 18604 logs/access.log 0:0:0:2.206
这样forever就帮助我们完成了,几项比较重要服务器管理功能:“启动/停止命令简单”,“支持热部署”,“宕机重启”,“监控界面和日志”。
比起upstart管理,省略了配置脚本的步骤(/etc/init/nodejs-xx.conf)。其他的功能,还要更近一步的使用才知道。
七、开发环境和生产环境的启动配置
开发环境
复制代码 代码如下:
~ cd /home/conan/nodejs/nodejs-forever/
~ forever -p . -l ./logs/access.log -e ./logs/error.log -a -w start app.js
生产环境
复制代码 代码如下:
~ export LOG=https://www.jb51.net/var/log/nodejs/project
~ export PID=https://www.jb51.net/var/log/nodejs/project/forever.pid
~ export APP_PATH=https://www.jb51.net/home/conan/nodejs/nodejs-forever
~ export APP=$APP_PATH/app.js
~ forever -p $APP_PATH -l $LOG/access.log -e $LOG/error.log -o $LOG/out.log -a --pidFile $PID start $APP
您可能感兴趣的文章: