2 # To the extent possible under law, Eric Wong has waived all copyright and
3 # related or neighboring rights to this examples
7 # Required-Start: $local_fs $network
8 # Required-Stop: $local_fs $network
9 # Default-Start: 2 3 4 5
11 # Short-Description: Start/stop yahns Ruby app server
14 # Feel free to change any of the following variables for your app:
16 APP_ROOT
=/home
/x
/my_app
/current
17 PID
=$APP_ROOT/tmp
/pids
/yahns.pid
18 CMD
="/usr/bin/yahns -D -c $APP_ROOT/config/yahns.rb"
19 INIT_CONF
=$APP_ROOT/config
/init.conf
20 UPGRADE_DELAY
=${UPGRADE_DELAY-2}
24 test -f "$INIT_CONF" && .
$INIT_CONF
28 cd $APP_ROOT ||
exit 1
31 test -s "$PID" && kill -$1 $
(cat $PID)
35 test -s "$OLD" && kill -$1 $
(cat $OLD)
40 sig
0 && echo >&2 "Already running" && exit 0
45 echo >&2 "Not running"
49 echo >&2 "Not running"
52 sig HUP
&& echo reloaded OK
&& exit 0
53 echo >&2 "Couldn't reload, starting '$CMD' instead"
59 echo >&2 "Old upgraded process still running with $OLD"
69 if test -n "$cur_pid" &&
70 kill -USR2 "$cur_pid" &&
71 sleep $UPGRADE_DELAY &&
72 new_pid
=$
(cat $PID) &&
73 test x
"$new_pid" != x
"$cur_pid" &&
78 while kill -0 "$cur_pid" 2>/dev
/null
&& test $n -ge 0
80 printf '.' && sleep 1 && n
=$
(( $n - 1 ))
84 if test $n -lt 0 && kill -0 "$cur_pid" 2>/dev
/null
86 echo >&2 "$cur_pid still running after $TIMEOUT seconds"
91 echo >&2 "Couldn't upgrade, starting '$CMD' instead"
98 echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"