cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eev...@apache.org
Subject git commit: refactor init script to use start-stop-daemon
Date Fri, 23 Aug 2013 14:59:11 GMT
Updated Branches:
  refs/heads/trunk 239e2d717 -> b224e58cb


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/b224e58c
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b224e58c
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b224e58c

Branch: refs/heads/trunk
Commit: b224e58cb6b44f98ec0f0e69fcc3833f60e962ce
Parents: 239e2d7
Author: Eric Evans <eevans@apache.org>
Authored: Thu Aug 15 18:19:50 2013 +0200
Committer: Eric Evans <eevans@apache.org>
Committed: Fri Aug 23 09:57:21 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/b224e58c/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/b224e58c/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/b224e58c/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


Mime
View raw message