Fix status check on stopping for rh cassandra script patch by Stefan Podkowinski; reviewed by Michael Shuler for CASSANDRA-13435
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/868be9c2 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/868be9c2 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/868be9c2 Branch: refs/heads/cassandra-3.11 Commit: 868be9c283e9a49f4a99b7bbeafde8ddd2f2d63f Parents: 5c6fc5e Author: Stefan Podkowinski <s.podkowin...@gmail.com> Authored: Wed Apr 12 16:47:05 2017 +0200 Committer: Stefan Podkowinski <s.podkowin...@gmail.com> Committed: Wed Apr 26 19:46:14 2017 +0200 ---------------------------------------------------------------------- redhat/cassandra | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/868be9c2/redhat/cassandra ---------------------------------------------------------------------- diff --git a/redhat/cassandra b/redhat/cassandra index 5ff9c48..a4aaaa5 100644 --- a/redhat/cassandra +++ b/redhat/cassandra @@ -67,16 +67,26 @@ case "$1" in su $CASSANDRA_OWNR -c "kill `cat $pid_file`" retval=$? [ $retval -eq 0 ] && rm -f $lock_file - for t in `seq 40`; do $0 status > /dev/null 2>&1 && sleep 0.5 || break; done + for t in `seq 40`; do + status -p $pid_file cassandra > /dev/null 2>&1 + retval=$? + if [ $retval -eq 3 ]; then + echo "OK" + exit 0 + else + sleep 0.5 + fi; + done # Adding a sleep here to give jmx time to wind down (CASSANDRA-4483). Not ideal... # Adam Holmberg suggests this, but that would break if the jmx port is changed # for t in `seq 40`; do netstat -tnlp | grep "0.0.0.0:7199" > /dev/null 2>&1 && sleep 0.1 || break; done sleep 5 - STATUS=`$0 status` - if [[ $STATUS == "$NAME is stopped" ]]; then + status -p $pid_file cassandra > /dev/null 2>&1 + retval=$? + if [ $retval -eq 3 ]; then echo "OK" else - echo "ERROR: could not stop $NAME: $STATUS" + echo "ERROR: could not stop $NAME" exit 1 fi ;;