InstallationGuidelines/Cherokee: cherokee

File cherokee, 2.2 KB (added by Praneeth Bodduluri, 13 years ago)
Line 
1#! /bin/sh
2#
3# start/stop Cherokee web server
4
5### BEGIN INIT INFO
6# Provides: cherokee
7# Required-Start: $remote_fs $network $syslog
8# Required-Stop: $remote_fs $network $syslog
9# Should-Start: $named
10# Should-Stop: $named
11# Default-Start: 2 3 4 5
12# Default-Stop: 0 1 6
13# Short-Description: Start the Cherokee Web server
14# Description: Start the Cherokee Web server
15### END INIT INFO
16
17PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
18DAEMON=/usr/local/sbin/cherokee
19NAME=cherokee
20PIDFILE=/var/run/cherokee.pid
21
22. /lib/lsb/init-functions
23
24set -e
25
26test -x $DAEMON || exit 0
27
28case "$1" in
29 start)
30 echo "Starting $NAME web server "
31 start-stop-daemon --start --oknodo --pidfile $PIDFILE --exec $DAEMON -b
32 ;;
33
34 stop)
35 echo "Stopping $NAME web server "
36 start-stop-daemon --stop --oknodo --pidfile $PIDFILE --exec $DAEMON
37 rm -f $PIDFILE
38 ;;
39
40 restart)
41 $0 stop
42 sleep 1
43 $0 start
44 ;;
45
46 reload|force-reload)
47 echo "Reloading web server "
48 if [ -f $PIDFILE ]
49 then
50 PID=$(cat $PIDFILE)
51 if ps p $PID | grep $NAME >/dev/null 2>&1
52 then
53 kill -HUP $PID
54 else
55 echo "PID present, but $NAME not found at PID $PID - Cannot reload"
56 exit 1
57 fi
58 else
59 echo "No PID file present for $NAME - Cannot reload"
60 exit 1
61 fi
62 ;;
63
64 status)
65 # Strictly, LSB mandates us to return indicating the different statuses,
66 # but that's not exactly Debian compatible - For further information:
67 # http://www.freestandards.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/iniscrptact.html
68 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=208010
69 # ...So we just inform to the invoker and return success.
70 echo "$NAME web server status"
71 if [ -e $PIDFILE ] ; then
72 PROCNAME=$(ps -p $(cat $PIDFILE) -o comm=)
73 if [ "x$PROCNAME" = "x" ]; then
74 echo "Not running, but PID file present"
75 else
76 if [ "$PROCNAME" = "$NAME" ]; then
77 echo "Running"
78 else
79 echo "PID file points to process '$PROCNAME', not '$NAME'"
80 fi
81 fi
82 else
83 if PID=$(pidofproc $DAEMON); then
84 echo "Running (PID $PID), but PIDFILE not present"
85 else
86 echo "Not running\t"
87 fi
88 fi
89 ;;
90
91 *)
92 N=/etc/init.d/$NAME
93 echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
94 exit 1
95 ;;
96esac
97
98exit 0