You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ee...@apache.org on 2010/11/25 00:01:02 UTC

svn commit: r1038861 - /cassandra/branches/cassandra-0.7/debian/init

Author: eevans
Date: Wed Nov 24 23:01:02 2010
New Revision: 1038861

URL: http://svn.apache.org/viewvc?rev=1038861&view=rev
Log:
make process liveness tests more robust

Patch by paul cannon; reviewed by eevans for CASSANDRA-1772

Modified:
    cassandra/branches/cassandra-0.7/debian/init

Modified: cassandra/branches/cassandra-0.7/debian/init
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/debian/init?rev=1038861&r1=1038860&r2=1038861&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/debian/init (original)
+++ cassandra/branches/cassandra-0.7/debian/init Wed Nov 24 23:01:02 2010
@@ -87,16 +87,21 @@ classpath()
 }
 
 #
-# Function that returns 0 if process is running, 1 if not
+# Function that returns 0 if process is running, or nonzero if not.
 #
+# The nonzero value is 3 if the process is simply not running, and 1 if the
+# process is not running but the pidfile exists (to match the exit codes for
+# the "status" command; see LSB core spec 3.1, section 20.2)
+#
+CMD_PATT="^`basename $JSVC`\.exec.*$NAME"
 is_running()
 {
     if [ -f $PIDFILE ]; then
-        if ps -p `cat $PIDFILE` &> /dev/null; then
-            return 0
-        fi
+        pid=`cat $PIDFILE`
+        grep -q "$CMD_PATT" "/proc/$pid/cmdline" 2>/dev/null && return 0
+        return 1
     fi
-    return 1
+    return 3
 }
 
 #
@@ -175,8 +180,18 @@ case "$1" in
 		;;
 	esac
 	;;
+  status)
+    is_running
+    stat=$?
+    case "$stat" in
+      0) log_success_msg "$DESC is running" ;;
+      1) log_failure_msg "could not access pidfile for $DESC" ;;
+      *) log_success_msg "$DESC is not running" ;;
+    esac
+    exit "$stat"
+    ;;
   *)
-	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
+	echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
 	exit 3
 	;;
 esac