2 Replies Latest reply on Feb 4, 2002 8:09 AM by Iulian State

    Shutting down jboss automatically

    neil mcclements Newbie

      Hi,

      I'd like to write a Linux shell script to stop jboss and retsrat it. I've tried using java - cp ../lib/ext/jboss.jar org.jboss.Shutdown $@ to no effect.

      Cany anyone suggest a good script for bouncing jboss (2.4.x) automatically?

      Tks.

        • 1. Re: Shutting down jboss automatically
          Iulian State Newbie

          I use to send a SIGINT (kill -s SIGINT pid_of_jboss) signal to the main process.

          Iulian

          • 2. Re: Shutting down jboss automatically
            Iulian State Newbie

            For the second part of the question I have

            /etc/init.d/jboss
            [pre]
            #!/bin/bash
            # Startup script for JBoss with Tomcat
            # chkconfig: - 84 16
            # description: JBoss application server
            # pidfile: /var/log/jboss/jboss.pid
            # processname: jboss

            DATE=`date`

            start() {
            echo "Starting JBoss:"
            su - webrun --command="${JBOSS_HOME}/bin/startup tomcat"
            sleep 20
            }

            stop() {
            echo "Shutting down JBoss with Tomcat"
            if [ -a ${JBOSS_HOME}/log/jboss.pid ] ; then
            pid=`cat ${JBOSS_HOME}/log/jboss.pid`
            if [ -d /proc/$pid ] ; then
            cmdline=`cat /proc/$pid/cmdline`
            if [ "${cmdline/*java*/java}" == "java" ] ; then
            su - webrun --command="echo === STOP: $DATE === >>${JBOSS_HOME}/log/jboss.log 2>&1 "
            kill -s SIGINT ${pid}
            rm -f ${JBOSS_HOME}/log/jboss.pid
            sleep 2
            return 0
            else
            echo "Warning: JBoss was not shutdown gracefully"
            return 0
            fi
            else
            echo "Warning: JBoss was not shutdown gracefully"
            rm -f ${JBOSS_HOME}/log/jboss.pid
            return 0
            fi
            else
            echo "JBoss is not running ..."
            fi
            }

            stat() {
            echo "Status"
            }

            case "$1" in
            start)
            start
            ;;
            stop)
            stop
            ;;
            restart)
            stop
            start
            ;;
            status)
            stat
            ;;
            *)
            echo "Usage: $0 {start|stop|restart|status}"
            exit 1
            esac
            [/pre]

            and $JBOSS_HOME/bin/startup

            [pre]#!/bin/sh

            BASEDIR=`dirname $0`
            pushd $BASEDIR > /dev/null

            DATE=`date`

            JBOSS_CLASSPATH=${JAVA_HOME}/lib/tools.jar:${JBOSS_DIST}/bin/run.jar:${JBOSS_DIST}/lib/crimson.jar

            HOTSPOT=`java -version 2>&1 | grep -i hotspot`
            if [ ! -z "${HOTSPOT}" ]; then
            HOTSPOT="-server"
            fi

            JAXP=-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.crimson.jaxp.DocumentBuilderFactoryImpl
            JAXP="$JAXP -Djavax.xml.parsers.SAXParserFactory=org.apache.crimson.jaxp.SAXParserFactoryImpl"

            echo " === START: ${DATE} === " >>${JBOSS_HOME}/log/jboss.log
            cmd="java ${HOTSPOT} ${JAXP} -classpath ${JBOSS_CLASSPATH} org.jboss.Main $@"
            ${cmd} >>${JBOSS_HOME}/log/jboss.log 2>&1 &
            echo $! > ${JBOSS_HOME}/log/jboss.pid
            [/pre]

            This is not completed, but it might be a good start

            Iulian