|
|
发表于 2018-4-18 15:07:24
|
显示全部楼层
本帖最后由 yumin9822 于 2018-4-18 15:09 编辑
开机启动脚本贡献一个
需要安装forever
修改DEAMON对应的参数,就可以了。另存为/etc/init.d/gdlist
- chmod a+x /etc/init.d/gdlist
- update-rc.d gdlist defaults
复制代码- #!/bin/bash
- ### BEGIN INIT INFO
- # Provides: nodejs
- # Required-Start: $local_fs $remote_fs
- # Required-Stop: $local_fs $remote_fs
- # Should-Start: $network
- # Should-Stop: $network
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: $DAEMON init script.
- # Description: Starts and stops $DAEMON daemon.
- ### END INIT INFO
- DEAMON=/root/gdlist/bin/www
- LOG=/var/log/nodejs_gd
- PID=/tmp/pid_gd
- 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
复制代码 |
|