Node. js boot script file, node. js Startup Script

Source: Internet
Author: User

Node. js boot script file, node. js Startup Script

Copy codeThe Code is 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 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 # enter the startup script file of your Node project.
LOG =/home/wwwroot/default/im/log # (optional) LOG file directory
PID =/home/wwwroot/default/im/log/pid # required content, used to record the forever process number
 
Export PATH = $ PATH:/usr/local/bin # specify the Node executable program installation directory here. My options are/usr/local/bin.
Export NODE_PATH = $ NODE_PATH:/usr/local/lib/node_modules # the path of the Node class library
 
# No need to modify the following content
 
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

Copy codeThe Code is as follows:
Chmod 755/etc/init. d/node
Chkconfig/etc/init. d/node on

Related Article

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.