[jboss-cvs] JBossAS SVN: r57513 - branches/Branch_4_0/system/src/bin

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Oct 9 13:41:38 EDT 2006


Author: dimitris at jboss.org
Date: 2006-10-09 13:41:36 -0400 (Mon, 09 Oct 2006)
New Revision: 57513

Modified:
   branches/Branch_4_0/system/src/bin/run.sh
Log:
JBAS-3748, allow run.sh to run in the background properly.

Modified: branches/Branch_4_0/system/src/bin/run.sh
===================================================================
--- branches/Branch_4_0/system/src/bin/run.sh	2006-10-09 17:38:43 UTC (rev 57512)
+++ branches/Branch_4_0/system/src/bin/run.sh	2006-10-09 17:41:36 UTC (rev 57513)
@@ -168,16 +168,43 @@
 echo "========================================================================="
 echo ""
 
-STATUS=10
-while [ $STATUS -eq 10 ]
-do
-# Execute the JVM
-   "$JAVA" $JAVA_OPTS \
-      -Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" \
-      -classpath "$JBOSS_CLASSPATH" \
-      org.jboss.Main "$@"
-   STATUS=$?
-   # if it doesn't work, you may want to take a look at this:
-   #    http://developer.java.sun.com/developer/bugParade/bugs/4465334.html
+while [ true ]; do
+   if [ "x$LAUNCH_JBOSS_IN_BACKGROUND" = "x" ]; then
+      # Execute the JVM in the foreground
+      "$JAVA" $JAVA_OPTS \
+         -Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" \
+         -classpath "$JBOSS_CLASSPATH" \
+         org.jboss.Main "$@"
+      JBOSS_STATUS=$?
+   else
+      # Execute the JVM in the background
+      "$JAVA" $JAVA_OPTS \
+         -Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" \
+         -classpath "$JBOSS_CLASSPATH" \
+         org.jboss.Main "$@" &
+      JBOSS_PID=$!
+      # Trap common signals and relay them to the jboss process
+      trap "kill -HUP  $JBOSS_PID" HUP
+      trap "kill -TERM $JBOSS_PID" INT
+      trap "kill -QUIT $JBOSS_PID" QUIT
+      trap "kill -PIPE $JBOSS_PID" PIPE
+      trap "kill -TERM $JBOSS_PID" TERM
+      # Wait until the background process exits
+      WAIT_STATUS=0
+      while [ "$WAIT_STATUS" -ne 127 ]; do
+         JBOSS_STATUS=$WAIT_STATUS
+         wait $JBOSS_PID 2>/dev/null
+         WAIT_STATUS=$?
+      done
+   fi
+   # If restart doesn't work, check you are running JBossAS 4.0.4+
+   #    http://jira.jboss.com/jira/browse/JBAS-2483
+   # or the following if you're running Red Hat 7.0
+   #    http://developer.java.sun.com/developer/bugParade/bugs/4465334.html   
+   if [ $JBOSS_STATUS -eq 10 ]; then
+      echo "Restarting JBoss..."
+   else
+      exit $JBOSS_STATUS
+   fi
 done
 




More information about the jboss-cvs-commits mailing list