Answer the question
In order to leave comments, you need to log in
Does anyone have an init.d script to run a node.js application under forever?
OS - CentOS 5.6
It needs to be launched at system startup forever, including the application script.
My knowledge was only enough for this:
#!/bin/sh
#
# chkconfig: - 85 15
# description: application
# processname: application.js
# Source function library.
. /etc/rc.d/init.d/functions
nodescript="application"
SOURCEDIR=/var/vhosts/application-server
DAEMON=$nodescript.js
OUTLOG=/var/log/$nodescript.output.log
ELOG=/var/log/$nodescript.err.log
SYSLOG=/var/log/$nodescript.forever.log
case "$1" in
start) forever -ao $OUTLOG -ae $ELOG --sourceDir $SOURCEDIR start $DAEMON
;;
stop)
forever stop $DAEMON ;;
restart)
forever restart $DAEMON ;;
*) echo "Usage: /etc/init.d/forever-application {start|stop|restart}"
exit 1 ;;
esac
exit 0
chkconfig --add forever-application
chkconfig --level 345 forever-application on
service forever-application start
runs the script, forever list
displays the script in the list of running ones. forever list
, it displays a message about the absence of running processes. ps awx | grep node
displays the process, i.e. forever, the script still launched, and everything works. Answer the question
In order to leave comments, you need to log in
Googled this with renewed vigor:
Running a Node.js Server as a Service Using Forever
Worked as it should
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question