zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iv...@apache.org
Subject svn commit: r1360311 - in /zookeeper/bookkeeper/trunk: CHANGES.txt bookkeeper-server/bin/bookkeeper-daemon.sh hedwig-server/bin/hedwig hedwig-server/bin/hedwig-daemon.sh hedwig-server/conf/hwenv.sh hedwig-server/conf/log4j.properties
Date Wed, 11 Jul 2012 17:24:48 GMT
Author: ivank
Date: Wed Jul 11 17:24:48 2012
New Revision: 1360311

URL: http://svn.apache.org/viewvc?rev=1360311&view=rev
Log:
BOOKKEEPER-329: provide stop scripts for hub server (sijie via ivank)

Added:
    zookeeper/bookkeeper/trunk/hedwig-server/bin/hedwig-daemon.sh   (with props)
Modified:
    zookeeper/bookkeeper/trunk/CHANGES.txt
    zookeeper/bookkeeper/trunk/bookkeeper-server/bin/bookkeeper-daemon.sh   (props changed)
    zookeeper/bookkeeper/trunk/hedwig-server/bin/hedwig
    zookeeper/bookkeeper/trunk/hedwig-server/conf/hwenv.sh
    zookeeper/bookkeeper/trunk/hedwig-server/conf/log4j.properties

Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1360311&r1=1360310&r2=1360311&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Wed Jul 11 17:24:48 2012
@@ -58,6 +58,8 @@ Trunk (unreleased changes)
 
         BOOKKEEPER-250: Need a ledger manager like interface to manage metadata operations
in Hedwig (sijie via ivank)
 
+        BOOKKEEPER-329: provide stop scripts for hub server (sijie via ivank)
+
 Release 4.1.0 - 2012-06-07
 
   Non-backward compatible changes:

Propchange: zookeeper/bookkeeper/trunk/bookkeeper-server/bin/bookkeeper-daemon.sh
------------------------------------------------------------------------------
    svn:executable = *

Modified: zookeeper/bookkeeper/trunk/hedwig-server/bin/hedwig
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/hedwig-server/bin/hedwig?rev=1360311&r1=1360310&r2=1360311&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/hedwig-server/bin/hedwig (original)
+++ zookeeper/bookkeeper/trunk/hedwig-server/bin/hedwig Wed Jul 11 17:24:48 2012
@@ -113,6 +113,9 @@ Environment variables:
    HEDWIG_CONSOLE_CLIENT_CONF   Client part configuration for hedwig console,
                                 used for interacting with hub server.
    HEDWIG_LOG_CONF              Log4j configuration file (default $DEFAULT_LOG_CONF)
+   HEDWIG_ROOT_LOGGER           Root logger for hedwig
+   HEDWIG_LOG_DIR               Log directory to store log files for hedwig server
+   HEDWIG_LOG_FILE              Log file name
    HEDWIG_EXTRA_OPTS            Extra options to be passed to the jvm
 
 These variable can also be set in conf/hwenv.sh
@@ -148,6 +151,18 @@ OPTS="-cp $HEDWIG_CLASSPATH $OPTS $HEDWI
 # Disable ipv6 as it can cause issues
 OPTS="$OPTS -Djava.net.preferIPv4Stack=true"
 
+# log directory & file
+HEDWIG_ROOT_LOGGER=${HEDWIG_ROOT_LOGGER:-"INFO,CONSOLE"}
+HEDWIG_LOG_DIR=${HEDWIG_LOG_DIR:-"$HW_HOME/logs"}
+HEDWIG_LOG_FILE=${HEDWIG_LOG_FILE:-"hedwig-server.log"}
+
+# Configure log configuration system properties
+OPTS="$OPTS -Dhedwig.root.logger=$HEDWIG_ROOT_LOGGER"
+OPTS="$OPTS -Dhedwig.log.dir=$HEDWIG_LOG_DIR"
+OPTS="$OPTS -Dhedwig.log.file=$HEDWIG_LOG_FILE"
+
+# Change to HW_HOME to support relative paths
+cd "$BK_HOME"
 if [ $COMMAND == "server" ]; then
     exec java $OPTS $JMX_ARGS org.apache.hedwig.server.netty.PubSubServer $HEDWIG_SERVER_CONF
$@
 elif [ $COMMAND == "console" ]; then

Added: zookeeper/bookkeeper/trunk/hedwig-server/bin/hedwig-daemon.sh
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/hedwig-server/bin/hedwig-daemon.sh?rev=1360311&view=auto
==============================================================================
--- zookeeper/bookkeeper/trunk/hedwig-server/bin/hedwig-daemon.sh (added)
+++ zookeeper/bookkeeper/trunk/hedwig-server/bin/hedwig-daemon.sh Wed Jul 11 17:24:48 2012
@@ -0,0 +1,163 @@
+#!/usr/bin/env bash
+#
+#/**
+# * Licensed to the Apache Software Foundation (ASF) under one
+# * or more contributor license agreements.  See the NOTICE file
+# * distributed with this work for additional information
+# * regarding copyright ownership.  The ASF licenses this file
+# * to you under the Apache License, Version 2.0 (the
+# * "License"); you may not use this file except in compliance
+# * with the License.  You may obtain a copy of the License at
+# *
+# *     http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# */
+
+usage() {
+    cat <<EOF
+Usage: hedwig-daemon.sh (start|stop) <command> <args...>
+where command is one of:
+    server           Run the hedwig server
+EOF
+}
+
+
+BINDIR=`dirname "$0"`
+HEDWIG_HOME=`cd $BINDIR/..;pwd`
+
+if [ -f $HEDWIG_HOME/conf/hwenv.sh ]
+then
+ . $HEDWIG_HOME/conf/hwenv.sh
+fi
+
+HEDWIG_LOG_DIR=${HEDWIG_LOG_DIR:-"$HEDWIG_HOME/logs"}
+
+HEDWIG_ROOT_LOGGER=${HEDWIG_ROOT_LOGGER:-'INFO,ROLLINGFILE'}
+
+HEDWIG_STOP_TIMEOUT=${HEDWIG_STOP_TIMEOUT:-30}
+
+HEDWIG_PID_DIR=${HEDWIG_PID_DIR:-$HEDWIG_HOME/bin}
+
+if [ $# -lt 2 ]
+then
+    echo "Error: no enough arguments provided."
+    usage
+    exit 1
+fi
+
+startStop=$1
+shift
+command=$1
+shift
+
+case $command in
+    (server)
+        echo "doing $startStop $command ..."
+        ;;
+    (*)
+        echo "Error: unknown service name $command"
+        usage
+        exit 1
+        ;;
+esac
+
+export HEDWIG_LOG_DIR=$HEDWIG_LOG_DIR
+export HEDWIG_ROOT_LOGGER=$HEDWIG_ROOT_LOGGER
+export HEDWIG_LOG_FILE=hedwig-$command-$HOSTNAME.log
+
+pid=$HEDWIG_PID_DIR/hedwig-$command.pid
+out=$HEDWIG_LOG_DIR/hedwig-$command-$HOSTNAME.out
+logfile=$HEDWIG_LOG_DIR/$HEDWIG_LOG_FILE
+
+rotate_out_log ()
+{
+    log=$1;
+    num=5;
+    if [ -n "$2" ]; then
+       num=$2
+    fi
+    if [ -f "$log" ]; then # rotate logs
+        while [ $num -gt 1 ]; do
+            prev=`expr $num - 1`
+            [ -f "$log.$prev" ] && mv "$log.$prev" "$log.$num"
+            num=$prev
+        done
+        mv "$log" "$log.$num";
+    fi
+}
+
+mkdir -p "$HEDWIG_LOG_DIR"
+
+case $startStop in
+  (start)
+    if [ -f $pid ]; then
+      if kill -0 `cat $pid` > /dev/null 2>&1; then
+        echo $command running as process `cat $pid`.  Stop it first.
+        exit 1
+      fi
+    fi
+
+    rotate_out_log $out
+    echo starting $command, logging to $logfile
+    hedwig=$HEDWIG_HOME/bin/hedwig
+    nohup $hedwig $command "$@" > "$out" 2>&1 < /dev/null &
+    echo $! > $pid
+    sleep 1; head $out
+    sleep 2;
+    if ! ps -p $! > /dev/null ; then
+      exit 1
+    fi
+    ;;
+
+  (stop)
+    if [ -f $pid ]; then
+      TARGET_PID=`cat $pid`
+      if kill -0 $TARGET_PID > /dev/null 2>&1; then
+        echo stopping $command
+        kill $TARGET_PID
+
+        count=0
+        location=$HEDWIG_LOG_DIR
+        while ps -p $TARGET_PID > /dev/null;
+         do
+          echo "Shutdown is in progress... Please wait..."
+          sleep 1
+          count=`expr $count + 1`
+         
+          if [ "$count" = "$HEDWIG_STOP_TIMEOUT" ]; then
+                break
+          fi
+         done
+        
+        if [ "$count" != "$HEDWIG_STOP_TIMEOUT" ]; then
+                 echo "Shutdown completed."
+                exit 0
+        fi
+                 
+        if kill -0 $TARGET_PID > /dev/null 2>&1; then
+              fileName=$location/$command.out
+              $JAVA_HOME/bin/jstack $TARGET_PID > $fileName
+              echo Thread dumps are taken for analysis at $fileName
+              echo forcefully stopping $command
+              kill -9 $TARGET_PID >/dev/null 2>&1
+              echo Successfully stopped the process
+        fi
+      else
+        echo no $command to stop
+      fi
+      rm $pid
+    else
+      echo no $command to stop
+    fi
+    ;;
+
+  (*)
+    usage
+    exit 1
+    ;;
+esac

Propchange: zookeeper/bookkeeper/trunk/hedwig-server/bin/hedwig-daemon.sh
------------------------------------------------------------------------------
    svn:executable = *

Modified: zookeeper/bookkeeper/trunk/hedwig-server/conf/hwenv.sh
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/hedwig-server/conf/hwenv.sh?rev=1360311&r1=1360310&r2=1360311&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/hedwig-server/conf/hwenv.sh (original)
+++ zookeeper/bookkeeper/trunk/hedwig-server/conf/hwenv.sh Wed Jul 11 17:24:48 2012
@@ -34,5 +34,14 @@
 # Log4j configuration file
 # HEDWIG_LOG_CONF=
 
+# Logs location
+# HEDWIG_LOG_DIR=
+
 # Extra options to be passed to the jvm
 # HEDWIG_EXTRA_OPTS=
+
+#Folder where the hedwig server PID file should be stored
+#HEDWIG_PID_DIR=
+
+#Wait time before forcefully kill the hedwig server instance, if the stop is not successful
+#HEDWIG_STOP_TIMEOUT=

Modified: zookeeper/bookkeeper/trunk/hedwig-server/conf/log4j.properties
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/hedwig-server/conf/log4j.properties?rev=1360311&r1=1360310&r2=1360311&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/hedwig-server/conf/log4j.properties (original)
+++ zookeeper/bookkeeper/trunk/hedwig-server/conf/log4j.properties Wed Jul 11 17:24:48 2012
@@ -26,7 +26,13 @@
 # Format is "<default threshold> (, <appender>)+
 
 # DEFAULT: console appender only
-log4j.rootLogger=WARN, CONSOLE
+# Define some default values that can be overridden by system properties
+hedwig.root.logger=WARN,CONSOLE
+hedwig.log.dir=.
+hedwig.log.file=hedwig-server.log
+hedwig.trace.file=hedwig-trace.log
+
+log4j.rootLogger=${hedwig.root.logger}
 
 # Example with rolling log file
 #log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE
@@ -47,12 +53,12 @@ log4j.appender.CONSOLE.layout.Conversion
 #    Log DEBUG level and above messages to a log file
 log4j.appender.ROLLINGFILE=org.apache.log4j.DailyRollingFileAppender
 log4j.appender.ROLLINGFILE.Threshold=INFO
-log4j.appender.ROLLINGFILE.File=hedwig-server.log
+log4j.appender.ROLLINGFILE.File=${hedwig.log.dir}/${hedwig.log.file}
 log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
 log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] -
%m%n
 
 # Max log file size of 10MB
-log4j.appender.ROLLINGFILE.MaxFileSize=10MB
+#log4j.appender.ROLLINGFILE.MaxFileSize=10MB
 # uncomment the next line to limit number of backup files
 #log4j.appender.ROLLINGFILE.MaxBackupIndex=10
 
@@ -65,7 +71,7 @@ log4j.appender.ROLLINGFILE.layout.Conver
 #    Log DEBUG level and above messages to a log file
 log4j.appender.TRACEFILE=org.apache.log4j.FileAppender
 log4j.appender.TRACEFILE.Threshold=TRACE
-log4j.appender.TRACEFILE.File=hedwig-trace.log
+log4j.appender.TRACEFILE.File=${hedwig.log.dir}/${hedwig.trace.file}
 
 log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout
 ### Notice we are including log4j's NDC here (%x)



Mime
View raw message