I
I
IonianWind2012-07-25 18:01:29
Node.js
IonianWind, 2012-07-25 18:01:29

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 startruns the script, forever listdisplays the script in the list of running ones.
After rebooting forever list, it displays a message about the absence of running processes.
However, it ps awx | grep nodedisplays the process, i.e. forever, the script still launched, and everything works.
What to fix so that scripts can manage standard forever commands?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IonianWind, 2012-07-26
@IonianWind

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 question

Ask a Question

731 491 924 answers to any question