node.js服务器开机启动失败,手动启动成功
用node.js搭建了一个服务器,并且写成了linux的一个service,开机运行,但是发现启动日志里面是失败的,手动运行service nodeserver start又成功了。
我的系统环境是centOS 5.7
这是/etc/init.d/nodeserver
#!/bin/bash
#
# chkconfig: 345 99 90
# description: this is a node server start script
#
# processname: node server
#
# Source function library.
. /etc/rc.d/init.d/functions
prog="node server"
RETVAL=0
log_file=/var/log/nodeserver.log
source /etc/profile
start() {
cd /home/GitHub/fpms/
daemon node server >> $log_file &
action "Strating $prog" /bin/true
return 0
}
stop() {
echo -n "Stop $prog"
killproc $prog
RETVAL=$?
echo
}
case "$1" in
start)
if [ $# -eq 2 ];then
export NODE_ENV=$2
start
else
export NODE_ENV=production
start
echo "usage:$0 start [production|development|test]|stop|restart [production|development|test]|status default production"
fi
;;
stop)
stop
;;
restart)
if [ $# -eq 2 ];then
export NODE_ENV=$2
stop
start
else
echo "usage:$0 start [production|development|test]|stop|restart [production|development|test]|status"
fi
;;
status)
status $prog
RETVAL=$?
;;
*)
echo "usage:$0 start [production|development|test]|stop|restart [production|development|test]|status"
echo 0;
esac
exit 0
下面是开机后看到的日志
Application loaded using the "production" environment configuration
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
宿主启动...
FPMS started on port 3000 and process.env.NODE_ENV = production
^[[60G[^[[0;31mFAILED^[[0;39m]^MApplication loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
Application loaded using the "production" environment configuration
日志中出现了FAILED,但是我开机后手动运行脚本并没有问题啊,求大神指导
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
搞定了
用npm install forever
然后修改nodeserver 那个service脚本的start函数为下面这个