Home > Web Front-end > JS Tutorial > node.js self-starting script file_node.js

node.js self-starting script file_node.js

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 16:24:40
Original
1563 people have browsed it

Copy code The 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 #Here you need to fill in the startup script file of your own Node project
LOG=/home/wwwroot/default/im/log/log #Optional, log file directory
PID=/home/wwwroot/default/im/log/pid #Required content, used to record the process number of forever

export PATH=$PATH:/usr/local/bin #Specify the Node executable program installation directory here, mine is /usr/local/bin
export NODE_PATH=$NODE_PATH:/usr/local/lib/node_modules #Here is the path to the Node class library

#There is no need to modify the content below

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 code The code is as follows:

chmod 755 /etc/init.d/node
chkconfig /etc/init.d/node on
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template