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