You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Tim McGuire <tm...@imbventures.com> on 2000/09/20 01:16:37 UTC

Help starting Tomcat

I just installed Tomcat 3.1, and have it working with virtual hosting in
Apache 1.3.12. I have three Tomcat servers configured.

I am having just a little trouble though. First, I cannot get Tomcat to
start when the system boots. (I have Redhat 6.2) I tried adding the startup
commands in /etc/rc.d/rc.local, but this did not work. How can I start
Tomcat without issuing the commands manually?

Second, I have three server.xml files (server1.xml, server2.xml and
server3.xml). I start Tomcat with:
startup.sh -f /usr/local/tomcat/conf/server1.xml
startup.sh -f /usr/local/tomcat/conf/server2.xml
startup.sh -f /usr/local/tomcat/conf/server3.xml

This works fine, but when I try to stop the servers, I get error messages
about not finding the configuration files. If I just use shutdown.sh without
trying to add a configuration file, it just stops server1. In this case,
server1.xml and server.xml have the same port number. How can I shut them
all down?

Thanks for the help,
Tim


Re: Help starting Tomcat

Posted by Andrew Cockburn <ac...@aqualog.co.uk>.
Hi Tim,

I wrote the following script for my Red Hat 6.2 system, and placed it in
/etc/rc.d/init.d.. I then added the appropriate links in /etc/rc.d/rc2.d to
ensure that tomcat is started before apache. i.e. I have the 2 following
links :

lrwxrwxrwx    1 root     root           16 Sep  3 17:39 S11tomcat ->
../init.d/tomcat
lrwxrwxrwx    1 root     root           16 Jul 13 16:47 S15apache ->
../init.d/apache

I also have the following links :

lrwxrwxrwx    1 root     root           16 Jul 13 16:47 K02apache ->
../init.d/apache
lrwxrwxrwx    1 root     root           16 Sep  3 17:41 K03tomcat ->
../init.d/tomcat

in /etc/rc.d/rc0.d and /etc/rc.d/rc6.d

This ensures that when runlevel 2 is reached (usually the default runlevel
on most systems) first tomcat then apache are started. During shutdown
(level 0) or reboot (level 6) apache is shutdown first, then tomcat. This
seems like the most sensible way of doing it to me. As far as the script
goes, the key to getting it working was making sure that all the environment
variables were set right, especially TOMCAT_HOME, and the path to the JDK
(you should change those to match your system) - this may have been your
problem in the first place.

Good luck !

Regards,

Andrew

---------------

#! /bin/sh
#
# chkconfig: - 60 20
# description: tomcat
# processname: java

# Get config.
. /etc/sysconfig/network

# Get functions
. /etc/rc.d/init.d/functions

# Check that networking is up.
if [ ${NETWORKING} = "no" ] ; then
        exit 0
fi

RETVAL=0

export TOMCAT_HOME=/opt/tomcat
export PATH=$PATH:/opt/jdk117_v3/bin

# See how we were called.
case "$1" in
  start)
        action "Starting tomcat" $TOMCAT_HOME/bin/startup.sh
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/tomcat
        touch /var/lock/subsys/tomcat
        ;;
  stop)
        action "Shutting down tomcat" $TOMCAT_HOME/bin/shutdown.sh
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/tomcat
        rm -f /var/lock/subsys/tomcat
        ;;
  status)
        status httpd
        RETVAL=$?
        ;;
  restart)
        $0 stop
        $0 start
        RETVAL=$?
        ;;
  *)
        echo "Usage: $0 {start|stop|status|restart}"
        exit 1
        ;;
esac

exit $RETVAL