You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Peter Björkman <pe...@josh.se> on 2007/03/11 23:22:11 UTC

Multiple instances problem...

Hi! I'm setting up an environment where I need a lot of differens web containers running, and part of that is setting up tomcat5.0 to run multiple instances.

I tried to find a startup/stop script and this is what I came up with:

#!/bin/bash
RETVAL=$?
# Installation directory
export CATALINA_HOME="/app/webcontainers/tomcat50"
# Configuration directory
export CATALINA_BASE="/etc/webcontainers/tomcat50/dev"
case "$1" in
 start)
        if [ -f $CATALINA_HOME/bin/startup.sh ];
          then
            echo $"Starting Tomcat"
            /bin/su tomcat $CATALINA_HOME/bin/startup.sh
        fi
        ;;
 stop)
        if [ -f $CATALINA_HOME/bin/shutdown.sh ];
          then
            echo $"Stopping Tomcat"
            /bin/su tomcat $CATALINA_HOME/bin/shutdown.sh
        fi
        ;;
 *)
        echo $"Usage: $0 {start|stop}"
        exit 1
        ;;
esac
exit $RETVAL

As you see I have tomcat installed under:
export CATALINA_HOME="/app/webcontainers/tomcat50"
And the base for this instance is:
export CATALINA_BASE="/etc/webcontainers/tomcat50/dev"

I then want to start a new instance on:
export CATALINA_BASE="/etc/webcontainers/tomcat50/live"

but that won't work, it randomly starts, stopping stops all instances and the general behaviour is strange.

Any ideas? Can you point me to a better startup script

Regards
Peter Björkman

PETER BJÖRKMAN - SYSTEM ARCHITECT
josh / together is better / www.josh.se
sveavagen 59 / 113 59 stockholm / sweden
phone +46 (0)8 650 21 07 / mobile +46 (0)709 687 884
###########################################

This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.f-secure.com/

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Multiple instances problem...

Posted by "Kirchhoff, Florian" <Fl...@qwest.com>.
Hi Peter,

are you making sure to use different ports for each instance
for Shutdown, HTTP/HTTPS and AJP?

Florian

-----Original Message-----
From: Peter Björkman [mailto:peter.bjorkman@josh.se] 
Sent: Sunday, March 11, 2007 6:22 PM
To: users@tomcat.apache.org
Subject: Multiple instances problem...


Hi! I'm setting up an environment where I need a lot of differens web containers running, and part of that is setting up tomcat5.0 to run multiple instances.

I tried to find a startup/stop script and this is what I came up with:

#!/bin/bash
RETVAL=$?
# Installation directory
export CATALINA_HOME="/app/webcontainers/tomcat50"
# Configuration directory
export CATALINA_BASE="/etc/webcontainers/tomcat50/dev"
case "$1" in
 start)
        if [ -f $CATALINA_HOME/bin/startup.sh ];
          then
            echo $"Starting Tomcat"
            /bin/su tomcat $CATALINA_HOME/bin/startup.sh
        fi
        ;;
 stop)
        if [ -f $CATALINA_HOME/bin/shutdown.sh ];
          then
            echo $"Stopping Tomcat"
            /bin/su tomcat $CATALINA_HOME/bin/shutdown.sh
        fi
        ;;
 *)
        echo $"Usage: $0 {start|stop}"
        exit 1
        ;;
esac
exit $RETVAL

As you see I have tomcat installed under:
export CATALINA_HOME="/app/webcontainers/tomcat50"
And the base for this instance is:
export CATALINA_BASE="/etc/webcontainers/tomcat50/dev"

I then want to start a new instance on:
export CATALINA_BASE="/etc/webcontainers/tomcat50/live"

but that won't work, it randomly starts, stopping stops all instances and the general behaviour is strange.

Any ideas? Can you point me to a better startup script

Regards
Peter Björkman

PETER BJÖRKMAN - SYSTEM ARCHITECT
josh / together is better / www.josh.se
sveavagen 59 / 113 59 stockholm / sweden phone +46 (0)8 650 21 07 / mobile +46 (0)709 687 884 ###########################################

This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.f-secure.com/


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Multiple instances problem...

Posted by Peter Björkman <pe...@josh.se>.
Thanks Christopher, works like a charm!

Regards
Peter

> 
> Peter,
> 
> Peter Björkman wrote:
> > Hi! I'm setting up an environment where I need a lot of 
> differens web
> > containers running, and part of that is setting up tomcat5.0 to run
> > multiple instances.
> > 
> > I tried to find a startup/stop script and this is what I came up
> > with:
> 
> [snip]
> 
> > but that won't work, it randomly starts, stopping stops all 
> instances
> > and the general behaviour is strange.
> > 
> > Any ideas? Can you point me to a better startup script
> 
> Not sure what's wrong with your script, but I have used this one for
> years. It's completely parameterized and intended to be used from ant,
> although there's no reason not to use it directly from the 
> command line.
> 
> Hope this helps,
> - -chris
> 
> #!/bin/sh
> # name: tomcat.sh
> # args:
> #       start|stop
> #       java-home=S             OPTIONAL (uses JAVA_HOME otherwise)
> #       tomcat-home=S           REQUIRED
> #       tomcat-port=N           REQUIRED
> #       tomcat-shutdown-port=n  REQUIRED
> #       project-base-dir=S      REQUIRED
> 
> SCRIPT=`basename $0`
> USAGE="usage: ${SCRIPT} start|stop [java-home=S] tomcat-home=S
> tomcat-port=N tomcat-shutdown-port=N project-base-dir=S"
> 
> while test $# -gt 0
> do
>         case "x$1" in
>         xstart)
>                 MODE=start
>                 ;;
>         xstop)
>                 MODE=stop
>                 ;;
>         xjava-home=*)
>                 JAVA_HOME=`expr $1 : 'java-home=\(.*\)'`
>                 ;;
>         xtomcat-port=*)
>                 TOMCAT_PORT=`expr $1 : 'tomcat-port=\(.*\)'`
>                 ;;
>         xtomcat-shutdown-port=*)
>                 TOMCAT_SHUTDOWN_PORT=`expr $1 :
> 'tomcat-shutdown-port=\(.*\)'`
>                 ;;
>         xproject-base-dir=*)
>                 PROJECT_BASE_DIR=`expr $1 : 'project-base-dir=\(.*\)'`
>                 ;;
>         xtomcat-home=*)
>                 TOMCAT_HOME=`expr $1 : 'tomcat-home=\(.*\)'`
>                 ;;
>         x*)
>                 echo "Invalid argument: $1."
>                 echo "${USAGE}"
>                 exit 1
>                 ;;
>         esac
>         shift
> done
> if test -z "${TOMCAT_PORT}" -o -z "${TOMCAT_SHUTDOWN_PORT}" -o -z
> "${PROJECT_BASE_DIR}" -o -z "${TOMCAT_HOME}"
> then
>         echo "${USAGE}"
>         exit 1
> fi
> case "x$MODE" in
> xstart|xstop)
>         ;;
> *)
>         echo "${USAGE}"
>         exit 1
>         ;;
> esac
> 
> CATALINA_BASE=$PROJECT_BASE_DIR
> 
> export TOMCAT_SHUTDOWN_PORT TOMCAT_PORT CATALINA_BASE TOMCAT_HOME
> 
> echo "${SCRIPT}: JAVA_HOME is $JAVA_HOME"
> echo "${SCRIPT}: TOMCAT_PORT is $TOMCAT_PORT"
> echo "${SCRIPT}: TOMCAT_SHUTDOWN_PORT is $TOMCAT_SHUTDOWN_PORT"
> echo "${SCRIPT}: CATALINA_BASE is $CATALINA_BASE"
> echo "${SCRIPT}: TOMCAT_HOME is $TOMCAT_HOME"
> 
> case "x${MODE}" in
> xstart)
>         echo "${SCRIPT} signing off - exec'ing 
> $TOMCAT_HOME/bin/startup.sh"
>         exec "$TOMCAT_HOME/bin/startup.sh"
>         ;;
> xstop)
>         echo "${SCRIPT} signing off - exec'ing 
> $TOMCAT_HOME/bin/shutdown.sh"
>         exec "$TOMCAT_HOME/bin/shutdown.sh"
>         ;;
> esac
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFF9WQ19CaO5/Lv0PARAryDAJ9BGZGW6xCMX+O55lnhyntw0E99RQCgg/71
> DPkGrIzaXMbwh+/5heCeTtc=
> =uOP+
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
###########################################

This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.f-secure.com/

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Multiple instances problem...

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter,

Peter Björkman wrote:
> Hi! I'm setting up an environment where I need a lot of differens web
> containers running, and part of that is setting up tomcat5.0 to run
> multiple instances.
> 
> I tried to find a startup/stop script and this is what I came up
> with:

[snip]

> but that won't work, it randomly starts, stopping stops all instances
> and the general behaviour is strange.
> 
> Any ideas? Can you point me to a better startup script

Not sure what's wrong with your script, but I have used this one for
years. It's completely parameterized and intended to be used from ant,
although there's no reason not to use it directly from the command line.

Hope this helps,
- -chris

#!/bin/sh
# name: tomcat.sh
# args:
#       start|stop
#       java-home=S             OPTIONAL (uses JAVA_HOME otherwise)
#       tomcat-home=S           REQUIRED
#       tomcat-port=N           REQUIRED
#       tomcat-shutdown-port=n  REQUIRED
#       project-base-dir=S      REQUIRED

SCRIPT=`basename $0`
USAGE="usage: ${SCRIPT} start|stop [java-home=S] tomcat-home=S
tomcat-port=N tomcat-shutdown-port=N project-base-dir=S"

while test $# -gt 0
do
        case "x$1" in
        xstart)
                MODE=start
                ;;
        xstop)
                MODE=stop
                ;;
        xjava-home=*)
                JAVA_HOME=`expr $1 : 'java-home=\(.*\)'`
                ;;
        xtomcat-port=*)
                TOMCAT_PORT=`expr $1 : 'tomcat-port=\(.*\)'`
                ;;
        xtomcat-shutdown-port=*)
                TOMCAT_SHUTDOWN_PORT=`expr $1 :
'tomcat-shutdown-port=\(.*\)'`
                ;;
        xproject-base-dir=*)
                PROJECT_BASE_DIR=`expr $1 : 'project-base-dir=\(.*\)'`
                ;;
        xtomcat-home=*)
                TOMCAT_HOME=`expr $1 : 'tomcat-home=\(.*\)'`
                ;;
        x*)
                echo "Invalid argument: $1."
                echo "${USAGE}"
                exit 1
                ;;
        esac
        shift
done
if test -z "${TOMCAT_PORT}" -o -z "${TOMCAT_SHUTDOWN_PORT}" -o -z
"${PROJECT_BASE_DIR}" -o -z "${TOMCAT_HOME}"
then
        echo "${USAGE}"
        exit 1
fi
case "x$MODE" in
xstart|xstop)
        ;;
*)
        echo "${USAGE}"
        exit 1
        ;;
esac

CATALINA_BASE=$PROJECT_BASE_DIR

export TOMCAT_SHUTDOWN_PORT TOMCAT_PORT CATALINA_BASE TOMCAT_HOME

echo "${SCRIPT}: JAVA_HOME is $JAVA_HOME"
echo "${SCRIPT}: TOMCAT_PORT is $TOMCAT_PORT"
echo "${SCRIPT}: TOMCAT_SHUTDOWN_PORT is $TOMCAT_SHUTDOWN_PORT"
echo "${SCRIPT}: CATALINA_BASE is $CATALINA_BASE"
echo "${SCRIPT}: TOMCAT_HOME is $TOMCAT_HOME"

case "x${MODE}" in
xstart)
        echo "${SCRIPT} signing off - exec'ing $TOMCAT_HOME/bin/startup.sh"
        exec "$TOMCAT_HOME/bin/startup.sh"
        ;;
xstop)
        echo "${SCRIPT} signing off - exec'ing $TOMCAT_HOME/bin/shutdown.sh"
        exec "$TOMCAT_HOME/bin/shutdown.sh"
        ;;
esac
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF9WQ19CaO5/Lv0PARAryDAJ9BGZGW6xCMX+O55lnhyntw0E99RQCgg/71
DPkGrIzaXMbwh+/5heCeTtc=
=uOP+
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org