首页 > 代码库 > linux centos6.2 node mongo 配置开机自启动
linux centos6.2 node mongo 配置开机自启动
#!/bin/bash
### BEGIN INIT INFO
# Provides: xiyoulib
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
# chkconfig: 345 88 08
# description: Forever for Node.js
DEAMON=/usr/local/src/node/pwp/server/mongo/getData.js
LOG=/usr/local/src/node/pwp/server/logs/forever.log
PID=/usr/local/src/node/pid
export PATH=$PATH:/usr/local/bin
export NODE_PATH=$NODE_PATH:/usr/local/lib/node_modules
node=node
forever=forever
case "$1" in
start)
$forever start -l $LOG --pidFile $PID -a $DEAMON
;;
stop)
$forever stop --pidFile $PID $DEAMON
;;
stopall)
$forever stopall --pidFile $PID
;;
restartall)
$forever restartall --pidFile $PID
;;
reload|restart)
$forever restart -l $LOG --pidFile $PID -a $DEAMON
;;
list)
$forever list
;;
*)
echo "Usage: /etc.init.d/node {start|stop|restart|reload|stopall|restartall|list}"
exit 1
;;
esac
以上代码是 node 的开机自启动及出错了以后自己启动的问题
是在 /etc/init.d/node 文件中配置
因为 forever 在rc.local 下是不能自启动的
配置mongo
echo "/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data/db --logpath=/usr/local/mongodb/logs/mongodb.log --fork" >> /etc/rc.local