[jboss-dev-forums] [Other JBoss Development Design] - Re: run.sh to launch JBoss in background

ips do-not-reply at jboss.com
Mon Oct 9 13:01:37 EDT 2006


Yep, java has to be started in the background. Here's what I ended up with. It works correctly on RHEL and Cygwin.


  | while [ 1 ]; do
  |    # Execute the JVM.
  |    "$JAVA" $JAVA_OPTS \
  |       -Djava.endorsed.dirs="$JBOSS_ENDORSED_DIRS" \
  |       -classpath "$JBOSS_CLASSPATH" \
  |       org.jboss.Main "$@" &
  |    JBOSS_PID=$!
  |    echo "JBOSS_PID: $JBOSS_PID"
  |    # Trap common signals and relay them to the JBoss process.
  |    trap "echo Received SIGHUP. ; kill -HUP  $JBOSS_PID" HUP
  |    trap "echo Received SIGINT. ; kill -TERM $JBOSS_PID" INT
  |    trap "echo Received SIGQUIT.; kill -QUIT $JBOSS_PID" QUIT
  |    trap "echo Received SIGPIPE.; kill -PIPE $JBOSS_PID" PIPE
  |    trap "echo Received SIGTERM.; kill -TERM $JBOSS_PID" TERM
  |    WAIT_STATUS=0
  |    while [ "$WAIT_STATUS" -ne 127 ]; do
  |       JBOSS_STATUS=$WAIT_STATUS
  |       wait $JBOSS_PID 2>/dev/null
  |       WAIT_STATUS=$?
  |    done
  |    if [ $JBOSS_STATUS -eq 10 ]; then
  |       echo Restarting JBossAS...
  |    else
  |       exit $JBOSS_STATUS
  |    fi
  |    # If restart doesn't work, see this if you're running JBossAS 4.0.4 or earlier:
  |    #    http://jira.jboss.com/jira/browse/JBAS-2483
  |    # or this if you're running Red Hat 7.0:
  |    #    http://developer.java.sun.com/developer/bugParade/bugs/4465334.html
  | done
  | 

I've attached a patch to http://jira.jboss.com/jira/browse/JBAS-3748. See my comment on that issue for an explanation of how I came up with the above.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3977025#3977025

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3977025



More information about the jboss-dev-forums mailing list