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 2013/08/23 16:58:31 UTC

git commit: refactor init script to use start-stop-daemon

Updated Branches:
  refs/heads/cassandra-2.0 ed79c1439 -> 56008de45


refactor init script to use start-stop-daemon

Patch by eevans; reviewed by brandon.williams for CASSANDRA-3991


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/56008de4
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/56008de4
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/56008de4

Branch: refs/heads/cassandra-2.0
Commit: 56008de4596c6885a12a22798a0fe777eb592aff
Parents: ed79c14
Author: Eric Evans <ee...@apache.org>
Authored: Thu Aug 15 18:19:50 2013 +0200
Committer: Eric Evans <ee...@apache.org>
Committed: Fri Aug 23 09:55:48 2013 -0500

----------------------------------------------------------------------
 bin/cassandra  | 12 ++++++++++--
 debian/control |  2 +-
 debian/init    | 54 +++++++++++++++++++++--------------------------------
 3 files changed, 32 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/56008de4/bin/cassandra
----------------------------------------------------------------------
diff --git a/bin/cassandra b/bin/cassandra
index 78d0660..e41385e 100755
--- a/bin/cassandra
+++ b/bin/cassandra
@@ -146,7 +146,7 @@ launch_service()
 }
 
 # Parse any command line options.
-args=`getopt vfhp:bD: "$@"`
+args=`getopt vfhp:bD:H:E: "$@"`
 eval set -- "$args"
 
 classname="org.apache.cassandra.service.CassandraDaemon"
@@ -162,7 +162,7 @@ while true; do
             shift
         ;;
         -h)
-            echo "Usage: $0 [-f] [-h] [-p pidfile]"
+            echo "Usage: $0 [-f] [-h] [-p pidfile] [-H dumpfile] [-E errorfile]"
             exit 0
         ;;
         -v)
@@ -173,6 +173,14 @@ while true; do
             properties="$properties -D$2"
             shift 2
         ;;
+        -H)
+            properties="$properties -XX:HeapDumpPath=$2"
+            shift 2
+        ;;
+        -E)
+            properties="$properties -XX:ErrorFile=$2"
+            shift 2
+        ;;
         --)
             shift
             break

http://git-wip-us.apache.org/repos/asf/cassandra/blob/56008de4/debian/control
----------------------------------------------------------------------
diff --git a/debian/control b/debian/control
index ac2c98b..bdee7df 100644
--- a/debian/control
+++ b/debian/control
@@ -11,7 +11,7 @@ Standards-Version: 3.8.3
 
 Package: cassandra
 Architecture: all
-Depends: openjdk-7-jre-headless | java7-runtime, jsvc (>= 1.0), libcommons-daemon-java (>= 1.0), adduser, libjna-java, python (>= 2.5), python-support (>= 0.90.0), ${misc:Depends}
+Depends: openjdk-7-jre-headless | java7-runtime, adduser, libjna-java, python (>= 2.5), python-support (>= 0.90.0), ${misc:Depends}
 Recommends: ntp
 Conflicts: apache-cassandra1
 Replaces: apache-cassandra1

http://git-wip-us.apache.org/repos/asf/cassandra/blob/56008de4/debian/init
----------------------------------------------------------------------
diff --git a/debian/init b/debian/init
index 99a4d83..66dd321 100644
--- a/debian/init
+++ b/debian/init
@@ -16,7 +16,7 @@
 
 DESC="Cassandra"
 NAME=cassandra
-PIDFILE=/var/run/$NAME.pid
+PIDFILE=/var/run/$NAME/$NAME.pid
 SCRIPTNAME=/etc/init.d/$NAME
 CONFDIR=/etc/cassandra
 JSVC=/usr/bin/jsvc
@@ -125,34 +125,22 @@ do_start()
     #   0 if daemon has been started
     #   1 if daemon was already running
     #   2 if daemon could not be started
-    is_running && return 1
 
     ulimit -l unlimited
     ulimit -n "$FD_LIMIT"
 
     cassandra_home=`getent passwd cassandra | awk -F ':' '{ print $6; }'`
-    cd /    # jsvc doesn't chdir() for us
-
-    $JSVC \
-        -user cassandra \
-        -home $JAVA_HOME \
-        -pidfile $PIDFILE \
-        -errfile "&1" \
-        -outfile /var/log/$NAME/output.log \
-        -cp `classpath` \
-        -Dlog4j.configuration=log4j-server.properties \
-        -Dlog4j.defaultInitOverride=true \
-        -XX:HeapDumpPath="$cassandra_home/java_`date +%s`.hprof" \
-        -XX:ErrorFile="$cassandra_home/hs_err_`date +%s`.log" \
-        $JVM_OPTS \
-        org.apache.cassandra.service.CassandraDaemon
-
-    is_running && return 0
-    for tries in `seq $WAIT_FOR_START`; do
-        sleep 1
-        is_running && return 0
-    done
-    return 2
+    heap_dump_f="$cassandra_home/java_`date +%s`.hprof"
+    error_log_f="$cassandra_home/hs_err_`date +%s`.log"
+
+    [ -e `dirname "PIDFILE"` ] || \
+        install -d -ocassandra -gcassandra -m750 `dirname $PIDFILE`
+
+    start-stop-daemon -S -c cassandra -a /usr/sbin/cassandra -q -p "$PIDFILE" -t >/dev/null || return 1
+
+    start-stop-daemon -S -c cassandra -a /usr/sbin/cassandra -b -p "$PIDFILE" -- \
+        -p "$PIDFILE" -H "$heap_dump_f" -E "$error_log_f" >/dev/null || return 2
+
 }
 
 #
@@ -160,15 +148,15 @@ do_start()
 #
 do_stop()
 {
-	# Return
-	#   0 if daemon has been stopped
-	#   1 if daemon was already stopped
-	#   2 if daemon could not be stopped
-	#   other if a failure occurred
-    is_running || return 1
-    $JSVC -stop -home $JAVA_HOME -pidfile $PIDFILE \
-            org.apache.cassandra.service.CassandraDaemon
-    is_running && return 2 || return 0
+    # Return
+    #   0 if daemon has been stopped
+    #   1 if daemon was already stopped
+    #   2 if daemon could not be stopped
+    #   other if a failure occurred
+    start-stop-daemon -K -p "$PIDFILE" -R TERM/30/KILL/5 >/dev/null
+    RET=$?
+    rm -f "$PIDFILE"
+    return $RET
 }
 
 case "$1" in