Node.js Boot self-starter script file _node.js

Source: Internet
Author: User

Copy Code code as follows:



#!/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 the boot time


# Description:enable service provided by Daemon.


### End INIT INFO


# chkconfig:345 88 08


# Description:forever for Node.js


 


deamon=/home/wwwroot/default/im/chat.js #这里需要填写你自己的Node项目的启动脚本文件


log=/home/wwwroot/default/im/log/log #可选, log file directory


pid=/home/wwwroot/default/im/log/pid #必填内容, used to record the forever process number





export path= $PATH:/usr/local/bin #在这里指定一下Node的可执行程序安装目录, mine is/usr/local/bin


export node_path= $NODE _path:/usr/local/lib/node_modules #这里是Node类库的路径


 


#往下的内容就不用修改了


 


Node=node


Forever=forever


 


case "$" 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


Copy Code code as follows:

chmod 755/etc/init.d/node
Chkconfig/etc/init.d/node on

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.