Anyone care to give this the once over and let me know what you think?  I
just realized I didn't check to see if this doc already existed =/  Anyway,
it needs work and a question or two answered (in <<< >>>), just wanted a TC4
smarty to make sure it wasn't completely off base =)

- r

                          Apache Tomcat 4.0
                          =================
                Running Multiple Instances of Tomcat
                ====================================

<<< CVS thingy here >>>

============
INTRODUCTION:
============

This document explains how to run multiple instances of Tomcat from a single
installation directory.  Why would you want to do this?  There are a number
of reasons:

    + One JVM per Tomcat instance means that a disruptive developer can't
      bring everyone else down.
    
    + Don't have to individually updated X number of Tomcat installs.
    
    + Single copy of startup/shutdown script used, so you don't have to
      customize it for each install.  Of course if a particular instance
      requires specialized startup/shutdown, you benefit from having all
      of the files here as well.

=========================
CREATING A NEW CONFIG FILE:
=========================

I usually start with a duplicate server.xml file, whose new name is prefixed
with the name of the user or group of users who will use that particular
instance.  For example, rslifka-server.xml or htmlguys-server.xml.  This gives
you the benefit of being able to create nifty startup and shutdown commands for
each user or group that requires their own version (an example of this is
provided later).

If you're going to be doing this a lot, it's a good idea to come up with a
template with placeholders for the important values, like "XXX" or "FIX ME".

    =====
    PORTS:
    =====

Which ports do you have to change?

() The <Server> element contains a "port" attribute.
() Each <Connector> child of a <Service> element contains a "port" attribute.

This is the most common place where mistakes are made.  One interesting port
scheme is the person's extension, + or - whatever numbers are necessary to
make it a valid port.  We have four digit extensions here, all greater than
1024, so we use them for the HTTP although you'll have to come up with your
own scheme for any internal ports.  This way, everyone knows the address of
everyone else's dev site, and you're guaranteed not to have any conflicts.

    ===========
    DIRECTORIES:
    ===========

<<< I can't figure out where to change the root (like in TC3.x the "home" attribute). 
>>>

In most cases, it's easier to just change the root than to change every single
log file that is generated by Tomcat, unless of course you have a very simple
installation.

    =========
    LOG FILES:
    =========

If you're sharing directories, you'll have to change log file names.

============================
STARTING AND STOPPING TOMCAT:
============================

You usually start and stop Tomcat like this:

    TOMCAT_HOME/bin/startup.X and shutdown.X
    
(where X is replaced by either "bat" or "sh").  These scripts use server.xml by
default, but if you provide the additional -f flag, you can specify which
configuration file to use, as such:

    TOMCAT_HOME/bin/startup.X -f TOMCAT_HOME/conf/rslifka-server.xml
    TOMCAT_HOME/bin/shutdown.X -f TOMCAT_HOME/conf/rslifka-server.xml

You might be wondering why you have to instruct the shutdown script to use the
server.xml as well.  This is because it needs to know about your configuration
in order to communicate with the container and instruct it to shutdown, among
other things.

    ====
    UNIX:
    ====

If you have $TOMCAT_HOME set for everyone who will be starting and stopping
their respective instance, then you can define nifty shortcuts for users in
their login scripts.

alias start-tc='$TOMCAT_HOME/bin/startup.sh -f $TOMCAT_HOME/conf/$USERNAME-server.xml'
alias stop-tc='$TOMCAT_HOME/bin/shutdown.sh -f $TOMCAT_HOME/conf/$USERNAME-server.xml'

    =======
    WINDOWS:
    =======

This is applicable to *nix as well, but since there aren't aliases in Windows,
I can't think of an alternative.  Place a .bat file in the shared /bin directory
and that batch file will do something like:

%TOMCAT_HOME%\bin\startup.bat -f %TOMCAT_HOME%\conf\%USERNAME%-server.xml

Reply via email to