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