On Wed, Jun 27, 2001 at 05:03:55PM +0200, Burkhard Vogel wrote:

> > I created an  init script for Linux SuSE and  I modified "run.sh" to
> > start,  stop, reload  and  query  the status  of  JBoss. Is  someone
> > interested ?
>
> Sure, post 'em. Burkhard

JBoss is installed in "/opt/JBoss-2.2.1_Jetty3.1.RC4", and there's a
link from "/opt/jboss" to "JBoss-2.2.1_Jetty3.1.RC4/jboss/" (In case
of multiple versions).
Both scripts must be executable :)

/etc/rc.d/jboss
---------------

Accepts  "start",  "stop",  "restart"  and  "status"  as  arguments.
Normaly  it is  used  via  a link  named  "rcjboss"  and present  in
"/usr/sbin".
JBoss is started as user  "snowflake", and the configuration file is
named "mapo".

---- Cut Here ---- Cut Here ---- Cut Here ----
#!/bin/sh
#
# Startup script for JBoss
# By Giambo <[EMAIL PROTECTED]>

. /etc/rc.config
. /etc/rc.status

# Where Java is installed
JAVA_HOME=/usr/lib/java
# PID-file
PID=/home/snowflake/.jboss.pid
# lock-file
LOCK=/var/lock/subsys/jboss
export JBOSS_HOME=/opt/jboss
export PATH=$PATH:$JBOSS_HOME/bin:$JAVA_HOME/bin:$JAVA_HOME/jre/bin

RETVAL=0

# See how we were called.
case "$1" in
        start)
                cd $JBOSS_HOME/bin
                echo -n "Starting jboss daemon: "
                if test -e $LOCK; then
                        echo -n "jboss already running !"
                        return=$rc_failed
                else
                        # Run jboss with permissions of user "snowflake"
                        su snowflake -c "$JBOSS_HOME/bin/run_daemon.sh mapo $PID"
                        RETVAL=$?
                        # If JBoss started without errors, creare lock-file
                        [ $RETVAL -eq 0 ] && touch $LOCK
                        # Wait 2 seconds (Good value for a very fast machine)
                        sleep 2
                        return=$rc_done
                fi
                echo -e "$return"
                ;;
        stop)
                echo -n "Stopping jboss daemon: "
                # PID-file exists ?
                if test -e $PID; then
                        # Kill JBoss
                        kill -9 `cat $PID`
                        RETVAL=$?
                        if [ $RETVAL -eq 0 ]; then
                                sleep 2
                                return=$rc_done
                        else
                                return=$rc_failed
                        fi
                        rm -f $LOCK
                else
                        echo -e "Couldn't find PID-file \"$PID\""
                        return=$rc_failed
                fi
                echo -e "$return"
                ;;
        restart)
                $0 stop
                $0 start
                ;;
        status)
                echo -n "Checking for jboss: "
                # Is JBoss already running ?
                if test -e $LOCK; then
                        echo "OK"
                else
                        echo "No process"
                fi
                ;;
        *)
        echo "Usage: $0 {start|stop|restart|status}"
esac
---- Cut Here ---- Cut Here ---- Cut Here ----

$JBOSS_HOME/bin/run_daemon.sh
-----------------------------

This is  a modified version of  run.sh. The most important  part are
the last two lines, where the  lock file and the file containing the
PID of JBoss are written.
The log of JBoss is placed in the homedir of the user "snowflake".

---- Cut Here ----
#!/bin/sh

# Minimal jar file to get JBoss started.
JBOSS_CLASSPATH=$JBOSS_CLASSPATH:run.jar

# Add the XML parser jars and set the JAXP factory names
# Crimson parser JAXP setup(default)
JBOSS_CLASSPATH=$JBOSS_CLASSPATH:../lib/crimson.jar
JAXP=-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.crimson.jaxp.DocumentBuilderFactoryImpl
JAXP="$JAXP 
-Djavax.xml.parsers.SAXParserFactory=org.apache.crimson.jaxp.SAXParserFactoryImpl"

/usr/lib/java/bin/java $JAXP -classpath $JBOSS_CLASSPATH org.jboss.Main $1 > 
/home/snowflake/logs/jboss.log 2>&1 &
echo $! > $2
---- Cut Here ----

In order to start and stop JBoss during the startup and the shutdown
of the machine, I  created two links from "/etc/rc.d/rc3.d/S10jboss"
and from "/etc/rc.d/rc3.d/K12jboss" to "/etc/rc.d/jboss". That means
JBoss is available only in the runlevel 3.

Please, feel free to contact me in case of errors or problems.

-- 
 __
| _         "The Internet is slow, could you please reboot it ?"
|__|iambo   mailto:[EMAIL PROTECTED]    www.giambonini.com

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to