centos forever node 开机自启动
2016-05-13 15:20
585 查看
1 进入 /etc/init.d, 新建文件 nodeserver(名字可以随便取)
cd /etc/init.d
touch nodeserver
2 编辑nodeserver
3 加入开机项:
chkconfig --add nodeserver
4 nodeserver命令
service nodeserver start
service nodeserver stop
service nodeserver restart
cd /etc/init.d
touch nodeserver
2 编辑nodeserver
#!/bin/sh # chkconfig: 2345 85 15 # description: Startup script for nodeserver. # exit on first error set -e # points to the root for forever config export "FOREVER_ROOT=/root/.forever" #LOG=/data/nodeserver/log PID=/data/nodeserver/pid starts=( "/usr/local/bin/forever --sourceDir /var/www/html/drunk start drunk.js" "/usr/local/bin/forever --sourceDir /var/www/html/wx start wxapi.js" ) # commands to run on "stop" (new line per command) stops=( "/usr/local/bin/forever stop --pidFile $PID /var/www/html/drunk/drunk.js" "/usr/local/bin/forever stop --pidFile $PID /var/www/html/wx/wxapi.js" ) # start function do_start(){ for i in "${starts[@]}" do $i done } # stop function do_stop(){ for i in "${stops[@]}" do $i done } # Decide what command is being called case "$1" in start) echo "Starting nodeserver..." do_start echo "done." ;; stop) echo "Stoping nodeserver..." do_stop echo "done." ;; restart) echo "Restarting nodeserver..." do_stop do_start echo "done." ;; *) echo "Usage: nodeserver {start|stop|restart}" >&2 exit 3 ;; esac exit 0
3 加入开机项:
chkconfig --add nodeserver
4 nodeserver命令
service nodeserver start
service nodeserver stop
service nodeserver restart
相关文章推荐
- 《Linux驱动》创建字符类设备节点
- linux学习(三):Linux文件系统管理
- centos7安装mysql5.x
- Linux下Nodejs安装(完整详细)
- Linux—档案与目录管理(1)
- linux下mysql命令大全
- linux之x86裁剪移植---ffmpeg的H264解码显示(420、422)
- linux之x86裁剪移植---ffmpeg的H264解码显示(420、422)
- LINUX下MYSQL的启动及相关配置
- linux之x86裁剪移植---ffmpeg的H264解码显示(420、422)
- linux之x86裁剪移植---ffmpeg的H264解码显示(420、422)
- Linux命令(3):chkconfig
- Linux流程解析三
- 《Linux驱动》注册字符类设备
- linux /etc/sysconfig/network-scripts/
- Linux中的文件描述符与打开文件之间的关系
- 基于centos6.7的Ceph分布式文件系统安装指南
- linux socket 客户端和服务器端 基础框架代码
- 对于Linux平台下C语言开发中__sync_函数的认识
- Linux 资源暂不可用或者unable to create new native thread