This looks pretty much like the one I use on openSuSE. The only difference is that I define the variables in a file in /etc/sysconfig.

/etc/sysconfig/tomcat contains.

CATALINA_BASE=
CATALINA_HOME=
TOMCAT_USER=
...

Then, the script sources that file with

. /etc/sysconfig/tomcat

If  I need to change a configuration setting, I'm not modifying a script.

johnrock wrote:
It took me quite a while but I finally got a tomcat startup script working
using jsvc to start as a tomcat user running on port 80.
Are there any drawbacks/cons to this method as opposed to NOT using jsvc and
instead running tomcat on 8080 and having the firewall redirect to this
port? Does using jsvc have any hidden ramifications?

Also, I am posting the startup file I came up with in the hopes that it will
either serve as a good example for anyone needing this solution or else
someone perhaps can spot any mistakes/problems it may contain.  It is
working on my system but I am not sure if I am missing anything.

Thanks!


#!/bin/sh
#
# chkconfig: 2345 85 15
# description: tomcat starts and stops apache-tomcat services.
# processname: tomcat
# pidfile: /var/run/tomcat.pid # Source function library.
. /etc/init.d/functions

# Read JAVA_HOME, JAVA_JRE, CATALINA_HOME environment variables
. /etc/profile


# Adapt the following lines to your configuration
DAEMON_HOME=$CATALINA_HOME/bin/jsvc
TOMCAT_USER=tomcat

# for multi instances adapt those lines.
TMP_DIR=/var/tmp
PID_FILE=/var/run/tomcat.pid
CATALINA_BASE=/usr/share/tomcat
CATALINA_HOME=/usr/share/tomcat
CATALINA_OPTS="-jvm server -Xms256M -Xmx256M -XX:MaxPermSize=256M"
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar

RETVAL=0

  start(){
    #
    # Start Tomcat
    #
    echo -n "Starting tomcat: "
    chown -R $TOMCAT_USER:$TOMCAT_USER /usr/share/tomcat/*
    $DAEMON_HOME \
    -user $TOMCAT_USER \
    -home $JAVA_HOME \
    -Dcatalina.home=$CATALINA_HOME \
    -Dcatalina.base=$CATALINA_BASE \
    -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \
    -Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties \
    -Djava.io.tmpdir=$TMP_DIR \
    -Djava.awt.headless=true \
    -wait 10 \
    -pidfile $PID_FILE \
    -outfile /var/log/tomcat/catalina.out \
    -errfile /var/log/tomcat/catalina.err \
    $CATALINA_OPTS \
    -cp $CLASSPATH \
    org.apache.catalina.startup.Bootstrap
    #
    # To get a verbose JVM
    #-verbose \
    # To get a debug of jsvc.
    #-debug \
  }
  stop(){
    #
    # Stop Tomcat
    #
    echo -n "Stopping tomcat: "
    $DAEMON_HOME \
    -stop \
    -pidfile $PID_FILE \
    org.apache.catalina.startup.Bootstrap
  }


# See how we were called.
case "$1" in
      start)
         if [ -f $PID_FILE ] ; then
            echo "Apache-Tomcat already running! Try STOP first..."
         else
            start
            fi
           ;;
        stop)
           stop
           ;;
        restart)
          stop
          sleep 5
          start
             ;;
status)
    if [[ -f $PID_FILE ]]
    then
      echo "found a pidfile so we are probably up and running."
    else
      echo "no pidfile so we are probably down."
    fi
    exit 1
    ;;

      *)
      echo "Usage: $0 {start|stop|restart|status}"
      exit 1
esac

exit $RETVAL


--
George Sexton
MH Software, Inc.
Voice: +1 303 438 9585
URL:   http://www.mhsoftware.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to