aboutsummaryrefslogtreecommitdiff
path: root/network/cherokee/rc.cherokee
blob: 381c011c031621e1c321cd4012a7d62e40eea188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh
#
# Start the Cherokee Web Server.
# http://www.cherokee-project.com/
#
# The following signals are supported by Cherokee:
# SIGHUP 	Restarts the server gracefully
# SIGUSR1 	Restarts the server closing all the opened connections
# SIGUSR2 	Reopens the log files
# SIGTERM 	Exits
#
# Written by Pablo Hernan Saro (pablosaro@gmail.com)

NAME=cherokee
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/lib/cherokee
DAEMON=/usr/sbin/cherokee
PIDFILE=/var/run/cherokee.pid
CONF=/etc/cherokee/cherokee.conf
OPTIONS="-d -C $CONF"

export PATH

test -f $DAEMON || exit 0

case "$1" in
  start)
    echo "Starting $NAME web server..."
    $DAEMON $OPTIONS
    sleep 2
    echo -n "done"
    ;;

  stop)
    echo "Stopping $NAME web server..."
    if [ -f $PIDFILE ]; then
	    PID=`cat $PIDFILE`
            kill -s TERM $PID
	    sleep 4
            echo -n "done"
    else
	    echo -n "Error: $PIDFILE does not exist."
    fi
    ;;

  reload)
    echo "Reloading $NAME configuration"
    if [ -f $PIDFILE ]; then
	    PID=`cat $PIDFILE`
            kill -s HUP $PID
	    sleep 3
            echo -n "done"
    else
	    echo -n "Error: $PIDFILE does not exist."
    fi
    ;;

  rotate-logs)
    echo "Rotating logs"
    if [ -f $PIDFILE ]; then
	    PID=`cat $PIDFILE`
            kill -s USR2 $PID
	    sleep 3
            echo -n "done"
    else
	    echo -n "Error: $PIDFILE does not exist."
    fi
    ;;

  restart)
    echo "Restarting the server closing all the opened connections"
    if [ -f $PIDFILE ]; then
	    PID=`cat $PIDFILE`
            kill -s USR1 $PID
	    sleep 4
            echo -n "done"
    else
	    echo -n "Error: $PIDFILE does not exist."
    fi
    ;;

  force-restart)
    $0 stop
    $0 start
    ;;

  *)
    echo "Usage: $0 {start|stop|reload|rotate-logs|restart|force-restart}"
    exit 1
    ;;
esac

if [ $? == 0 ]; then
	echo .
	exit 0
else
	echo failed
	exit 1
fi