OK.  I've got a much better version of this working now based on Toby's suggestion.  This is actually working quite well.   I haven't tested this with EmbeddedTomcat yet, but I don't forsee a problem.  InstantDB does not work properly, as it uses a relative path.  I would suggest doing the jboss.home property treatment, similar to what I did to org.jboss.Main.  I don't use InstantDB, so removing it's entry from jboss.conf fixed that for me.  YMMV.

It does require a patch to 1 line of org.jboss.Main.  This patch and the changes to the shell scripts below will make it possible to start and stop jBoss from any directory (no cd'ing to jboss_home/bin required)
*** Main.java.orig        Tue Nov 14 18:22:34 2000
--- Main.java        Tue Nov 14 18:23:15 2000
***************
*** 105,111 ****
           final MBeanServer server = MBeanServerFactory.createMBeanServer();
     
           // Add configuration directory to MLet
!          URL confDirectory = new File("../conf/"+confName).getCanonicalFile().toURL();
           
           // Create MLet
           MLet mlet = new MLet(new URL[] { confDirectory });
--- 105,111 ----
           final MBeanServer server = MBeanServerFactory.createMBeanServer();
     
           // Add configuration directory to MLet
!          URL confDirectory = new File(System.getProperty("jboss.home") + "/conf/"+confName).getCanonicalFile().toURL();
           
           // Create MLet
           MLet mlet = new MLet(new URL[] { confDirectory });


Here are modified versions of run.sh, plus a setenv.sh and shutdown.sh (put these in the jboss bin directory):
run.sh:
#!/bin/sh

# Minimal jar file to get JBoss started.

. `dirname $0`/setenv.sh

CLASSPATH=$CLASSPATH:$JBOSS_HOME/bin/run.jar

if [ "${TOMCAT_HOME}X" != "X" ] ; then
    if [ -x $TOMCAT_HOME ] ; then
        echo "Adding jar files in ${TOMCAT_HOME}/lib to CLASSPATH"
        CLASSPATH="$CLASSPATH:${TOMCAT_HOME}/lib"
        CLASSPATH="$CLASSPATH:${TOMCAT_HOME}/lib/servlet.jar"
        CLASSPATH="$CLASSPATH:${TOMCAT_HOME}/lib/webserver.jar"
        CLASSPATH="$CLASSPATH:${TOMCAT_HOME}/lib/xml.jar"
        CLASSPATH="$CLASSPATH:${TOMCAT_HOME}/lib/jaxp.jar"
        CLASSPATH="$CLASSPATH:${TOMCAT_HOME}/lib/parser.jar"
        CLASSPATH="$CLASSPATH:${TOMCAT_HOME}/lib/jasper.jar"

        # Add the tools.jar file so that Tomcat can find the Java compiler.
        CLASSPATH="$CLASSPATH:$JAVA_HOME/lib/tools.jar"
    else
        echo "TOMCAT_HOME is set, but is an invalid directory"
    fi
fi

#if [ "${SPYDERMQ_HOME}X" != "X" ] ; then
#    if [ -x $SPYDERMQ_HOME ] ; then
#        echo "Adding jar files in ${SPYDERMQ_HOME}/lib to CLASSPATH"
#        CLASSPATH="$CLASSPATH:${SPYDERMQ_HOME}/lib/spydermq.jar"
#        CLASSPATH="$CLASSPATH:${SPYDERMQ_HOME}/lib/jms.jar"
#        CLASSPATH="$CLASSPATH:${SPYDERMQ_HOME}/lib/jnpserver.jar"
#    else
#        echo "SPYDERMQ_HOME is set, but is an invalid directory"
#    fi
#fi

# Add all login modules for JAAS-based security
# and all libraries that are used by them here
#CLASSPATH="$CLASSPATH:../lib/jdbc2_0-stdext.jar:../lib/jboss-jaas.jar"
CLASSPATH="$CLASSPATH:$JBOSS_HOME/lib/jdbc2_0-stdext.jar:$JBOSS_HOME/lib/jboss-jaas.jar"

#echo $CLASSPATH
java -server -classpath $CLASSPATH -Djboss.home=$JBOSS_HOME -Dtomcat.home=$TOMCAT_HOME org.jboss.Main $@ &
echo $! > $PID
-------------------------

setenv.sh:
#!/bin/sh

JBOSS_HOME=`dirname $0`/..
JAVA_HOME=/usr/local/jdk1.3
PID=$JBOSS_HOME/tmp/jboss.pid
PATH=$PATH:$JBOSS_HOME/bin:$JAVA_HOME/bin
export JBOSS_HOME PID PATH
-------------------------

shutdown.sh:
#!/bin/sh

. `dirname $0`/setenv.sh

if [ -a $PID ] ; then
  kill `cat $PID`
  rm $PID
else
  echo ""
  echo "Couldn't find the pid file at $PID"
  echo "Is jBoss running?"
  echo ""
fi


On RedHat, this script can be put in /etc/rc.d/init.d, and then symlinked to the appropriate runlevel directory:
jboss:
#!/bin/bash
#
# jboss:        This file will start and stop jboss
#
# Author:       Jason Vasquez ([EMAIL PROTECTED])
#

JBOSS_HOME=/opt/jboss

# See how we were called.
case "$1" in
  stop)
        echo="Stopping jBoss..."
        $JBOSS_HOME/bin/shutdown.sh
        ;;
  start)
        echo="Starting jBoss..."
        $JBOSS_HOME/bin/run.sh
        ;;
  *)
        echo "$0: call me as \"jboss start\" or \"jboss stop\" please!"
        exit 1
        ;;
esac





[EMAIL PROTECTED]

11/14/00 03:54 PM
Please respond to jBoss

       
        To:        jBoss <[EMAIL PROTECTED]>
        cc:        
        Subject:        Re: [jBoss-User] Starting and stopping jboss automatically in *nix



wow.  that is so much better than my way.  I wish I had thought of this earlier today!


Thanks for the tip.

I'm going to go ahead and put together some start and stop scripts that will work with Linux based on this method...


Thanks,
Jason




Toby Allsopp <[EMAIL PROTECTED]>

11/14/2000 03:06 PM
Please respond to jBoss

       
       To:        jBoss <[EMAIL PROTECTED]>

       cc:        

       Subject:        Re: [jBoss-User] Starting and stopping jboss automatically in *nix



Hi. In my company we use a start script (this is for WebLogic, but the
principle's the same) that record the pid. In sh, you can get the pid of
the process you just started using $!, so we do

java -classpath ... -Detc=whatever weblogic.Server > server.out 2>&1 &
echo $! > PID

and then to stop it it's simply

kill `cat PID`

Regards,
Toby.

[EMAIL PROTECTED] wrote:
>
> Let me preface this by saying that this is a horrible hack--it seems
> to work for me today, but if you're interested, try it out and let me
> know...
>

--
Toby Allsopp
Research
Peace Software International Ltd
Ph +64-9-3730400


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]




Reply via email to