]>
Commit | Line | Data |
---|---|---|
3f05bde6 MK |
1 | #!/bin/sh |
2 | # | |
087ae4ed | 3 | # cassandra Cassandra |
3f05bde6 | 4 | # |
087ae4ed | 5 | # chkconfig: 345 84 25 |
3f05bde6 MK |
6 | # |
7 | # description: Cassandra database node | |
8 | # | |
087ae4ed | 9 | # processname: cassandra |
3f05bde6 MK |
10 | |
11 | # Source function library | |
12 | . /etc/rc.d/init.d/functions | |
13 | ||
14 | # Get network config | |
15 | . /etc/sysconfig/network | |
16 | ||
3f05bde6 | 17 | # Get service config - may override defaults |
e0f7348d | 18 | [ -f /etc/sysconfig/cassandra ] && . /etc/sysconfig/cassandra |
3f05bde6 MK |
19 | |
20 | # Check that networking is up. | |
21 | if is_yes "${NETWORKING}"; then | |
22 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then | |
e0f7348d | 23 | msg_network_down "cassandra" |
3f05bde6 MK |
24 | exit 1 |
25 | fi | |
26 | else | |
27 | exit 0 | |
28 | fi | |
29 | ||
3f05bde6 MK |
30 | start() { |
31 | # Check if the service is already running? | |
e0f7348d ER |
32 | if [ -f /var/lock/subsys/cassandra ]; then |
33 | msg_already_running "cassandra" | |
34 | return | |
3f05bde6 | 35 | fi |
e0f7348d ER |
36 | |
37 | msg_starting "cassandra" | |
38 | daemon --user cassandra /usr/sbin/cassandra -p /var/run/cassandra/cassandra.pid | |
39 | RETVAL=$? | |
40 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cassandra | |
3f05bde6 MK |
41 | } |
42 | ||
43 | ||
44 | stop() { | |
e0f7348d ER |
45 | if [ ! -f /var/lock/subsys/cassandra ]; then |
46 | msg_not_running "cassandra" | |
47 | return | |
48 | fi | |
49 | ||
50 | # Stop daemons. | |
51 | msg_stopping "cassandra" | |
52 | # TODO: Fix it to work it properly with default PLD starting script scheme | |
53 | # I do not know how to make | |
54 | pid=$(cat /var/run/cassandra/cassandra.pid) | |
55 | kill -TERM $pid | |
56 | # 0 - call succeed | |
57 | RETVAL=$? | |
58 | if [ $RETVAL -eq 0 ]; then | |
59 | # Success, giving some time for cassandra to flush. | |
60 | checkpid $pid && sleep 1 | |
61 | checkpid $pid && sleep 3 | |
62 | checkpid $pid && sleep 5 | |
63 | if checkpid $pid; then | |
16c24e02 MK |
64 | fail |
65 | log_failed "cassandra shutdown (timeout after -TERM)" | |
e0f7348d | 66 | else |
16c24e02 MK |
67 | ok |
68 | log_success "cassandra shutdown" | |
16c24e02 | 69 | fi |
3f05bde6 | 70 | else |
e0f7348d ER |
71 | fail |
72 | log_failed "cassandra shutdown (signalling error)" | |
3f05bde6 | 73 | fi |
e0f7348d | 74 | rm -f /var/lock/subsys/cassandra |
3f05bde6 MK |
75 | } |
76 | ||
77 | condrestart() { | |
e0f7348d ER |
78 | if [ ! -f /var/lock/subsys/cassandra ]; then |
79 | msg_not_running "cassandra" | |
3f05bde6 | 80 | RETVAL=$1 |
e0f7348d | 81 | return |
3f05bde6 | 82 | fi |
e0f7348d ER |
83 | |
84 | stop | |
85 | start | |
3f05bde6 MK |
86 | } |
87 | ||
88 | RETVAL=0 | |
89 | # See how we were called. | |
90 | case "$1" in | |
91 | start) | |
92 | start | |
93 | ;; | |
94 | stop) | |
95 | stop | |
96 | ;; | |
97 | restart) | |
98 | stop | |
99 | start | |
100 | ;; | |
101 | try-restart) | |
102 | condrestart 0 | |
103 | ;; | |
104 | force-reload) | |
105 | condrestart 7 | |
106 | ;; | |
107 | status) | |
108 | # Does not work with /usr/sbin/cassandra for some reason | |
109 | status cassandra | |
110 | ;; | |
111 | *) | |
3f05bde6 MK |
112 | msg_usage "$0 {start|stop|restart|try-restart|force-reload}" |
113 | exit 3 | |
114 | esac | |
115 | ||
116 | exit $RETVAL |