[jboss-cvs] JBossAS SVN: r99350 - branches/JBPAPP_5_0/server/src/bin.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 13 12:05:27 EST 2010


Author: bshim
Date: 2010-01-13 12:05:27 -0500 (Wed, 13 Jan 2010)
New Revision: 99350

Modified:
   branches/JBPAPP_5_0/server/src/bin/jboss_init_redhat.sh
Log:
fix for JBPAPP-3029 - better script

Modified: branches/JBPAPP_5_0/server/src/bin/jboss_init_redhat.sh
===================================================================
--- branches/JBPAPP_5_0/server/src/bin/jboss_init_redhat.sh	2010-01-13 17:01:35 UTC (rev 99349)
+++ branches/JBPAPP_5_0/server/src/bin/jboss_init_redhat.sh	2010-01-13 17:05:27 UTC (rev 99350)
@@ -23,15 +23,12 @@
 #make sure java is in your path
 JAVAPTH=${JAVAPTH:-"/usr/local/jdk/bin"}
 
-#configuration to use, usually one of 'minimal', 'default', 'all'
+#configuration to use, usually one of 'minimal', 'default', 'all', 'production'
 JBOSS_CONF=${JBOSS_CONF:-"default"}
 
 #if JBOSS_HOST specified, use -b to bind jboss services to that address
 JBOSS_BIND_ADDR=${JBOSS_HOST:+"-b $JBOSS_HOST"}
 
-#define the classpath for the shutdown class
-JBOSSCP=${JBOSSCP:-"$JBOSS_HOME/bin/shutdown.jar:$JBOSS_HOME/client/jnet.jar"}
-
 #define the script to use to start jboss
 JBOSSSH=${JBOSSSH:-"$JBOSS_HOME/bin/run.sh -c $JBOSS_CONF $JBOSS_BIND_ADDR"}
 
@@ -59,7 +56,6 @@
 JBOSS_CONSOLE=${JBOSS_CONSOLE:-"/dev/null"}
 
 JBOSS_CMD_START="cd $JBOSS_HOME/bin; $JBOSSSH"
-JBOSS_CMD_STOP=${JBOSS_CMD_STOP:-"java -classpath $JBOSSCP org.jboss.Shutdown --shutdown"}
 
 if [ -z "`echo $PATH | grep $JAVAPTH`" ]; then
   export PATH=$PATH:$JAVAPTH
@@ -72,6 +68,63 @@
 
 echo JBOSS_CMD_START = $JBOSS_CMD_START
 
+function procrunning() {
+   procid=0
+   JBOSSSCRIPT=$(echo $JBOSSSH | awk '{print $1}' | sed 's/\//\\\//g')
+   for procid in `/sbin/pidof -x "$JBOSSSCRIPT"`; do
+       ps -fp $procid | grep "${JBOSSSH% *}" > /dev/null && pid=$procid
+   done
+}
+
+
+stop() {
+    pid=0
+    procrunning
+    if [ $pid = '0' ]; then
+        echo -n -e "\nNo JBossas is currently running\n"
+        exit 1
+    fi
+
+    RETVAL=1
+
+    # If process is still running
+
+    # First, try to kill it nicely
+    for id in `ps --ppid $pid | awk '{print $1}' | grep -v "^PID$"`; do
+       if [ -z "$SUBIT" ]; then
+           kill -15 $id
+       else
+           $SUBIT "kill -15 $id"
+       fi
+    done
+
+    sleep=0
+    while [ $sleep -lt 120 -a $RETVAL -eq 1 ]; do
+        echo -n -e "\nwaiting for processes to stop";
+        sleep 10
+        sleep=`expr $sleep + 10`
+        pid=0
+        procrunning
+        if [ $pid == '0' ]; then
+            RETVAL=0
+        fi
+    done
+
+    # Still not dead... kill it
+
+    count=0
+    pid=0
+    procrunning
+
+    if [ $RETVAL != 0 ] ; then
+        echo -e "\nTimeout: Shutdown command was sent, but process is still running with PID $pid"
+        exit 1
+    fi
+
+    echo
+    exit 0
+}
+
 case "$1" in
 start)
     cd $JBOSS_HOME/bin
@@ -82,11 +135,7 @@
     fi
     ;;
 stop)
-    if [ -z "$SUBIT" ]; then
-        $JBOSS_CMD_STOP
-    else
-        $SUBIT "$JBOSS_CMD_STOP"
-    fi 
+    stop
     ;;
 restart)
     $0 stop




More information about the jboss-cvs-commits mailing list