From 13bf64530bd99c7e2ec412d20c7a471c89491815 Mon Sep 17 00:00:00 2001 From: kpdecker Date: Sun, 27 Mar 2011 18:23:32 -0500 Subject: [PATCH] Add custom root directory to the initd-example (For cases where /tmp is removed) --- examples/initd-example | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/initd-example b/examples/initd-example index b37cbdca..7c0307a4 100644 --- a/examples/initd-example +++ b/examples/initd-example @@ -20,6 +20,7 @@ SOURCE_NAME=main.js # Name os the applcation entry point script user=apache pidfile=/var/run/$NAME.pid logfile=/var/log/$NAME.log +forever_dir=/var/run/forever # Forever root directory. node=node forever=forever @@ -40,7 +41,7 @@ start() { # Launch the application daemon --user=$user \ env PORT=$PORT \ - $forever start --pidfile $pidfile -l $logfile -a -d $INSTANCE_DIR $SOURCE_NAME + $forever start -p $forever_dir --pidfile $pidfile -l $logfile -a -d $INSTANCE_DIR $SOURCE_NAME RETVAL=$? else echo "Instance already running" @@ -51,7 +52,7 @@ start() { restart() { echo -n "Restarting $NAME node instance : " if [ "$id" != "" ]; then - $forever restart $id + $forever restart -p $forever_dir $id RETVAL=$? else start @@ -61,7 +62,7 @@ restart() { stop() { echo -n "Shutting down $NAME node instance : " if [ "$id" != "" ]; then - $forever stop $id + $forever stop -p $forever_dir $id else echo "Instance is not running"; fi @@ -70,7 +71,7 @@ stop() { getForeverId() { local pid=$(pidofproc $pidfile) - $forever list | $sed -e 's/\x1b\[[0-9; ]*m//g' | $awk "\$4 == \"$pid]\" { gsub(/[\[\]]/, \"\", \$1); print \$1; }" + $forever list -p $forever_dir | $sed -e 's/\x1b\[[0-9; ]*m//g' | $awk "\$4 == \"$pid]\" { gsub(/[\[\]]/, \"\", \$1); print \$1; }" } id=$(getForeverId)