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,但是我开机后手动运行脚本并没有问题啊,求大神指导
秀巴爾利斯
9 years, 11 months ago