Skip to content

Commit

Permalink
Add custom root directory to the initd-example (For cases where /tmp …
Browse files Browse the repository at this point in the history
…is removed)
  • Loading branch information
kpdecker committed Mar 27, 2011
1 parent b181dd7 commit 13bf645
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions examples/initd-example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit 13bf645

Please sign in to comment.