You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Marc Prud'hommeaux <ma...@apocalypse.org> on 2000/05/24 00:23:47 UTC

Using system properties to configure Tomcat?

Is it possible to configure the standalone Tomcat with System properties
instead of the servlet.xml file? We have a development environment where
all the developers need to run the servlet themselves on separate ports
and with separate document roots, and we would like to be able to
configure the Tomcat parameters (document root, port, etc) using
system properties rather than having to generate a servler.xml file with a
script whenever they run the server.

Thanks in advance,

Marc


Re: Using system properties to configure Tomcat?

Posted by Anke Steuernagel <an...@opus5.de>.
On Tue, May 23, 2000 at 03:23:47PM -0700, Marc Prud'hommeaux wrote:
> 
> Is it possible to configure the standalone Tomcat with System properties
> instead of the servlet.xml file? We have a development environment where
> all the developers need to run the servlet themselves on separate ports
> and with separate document roots, and we would like to be able to
> configure the Tomcat parameters (document root, port, etc) using
> system properties rather than having to generate a servler.xml file with a
> script whenever they run the server.

Hi Marc,

as nobody answered to your question until now, take a look on our solution:
A start script for /bin/bash. 
-------------------------------------------------------------------------
export TOMCAT_HOME=${PROJECT_HOME}/jakarta-tomcat
export JAVA_HOME=${PROJECT_HOME}/jdk1.2.2
export ANT_HOME=${PROJECT_HOME}/jakarta-ant
export PATH=${JAVA_HOME}/bin:${ANT_HOME}/bin:${PATH}

export USER_ID=`id -u`
export TOMCAT_PORT=$[${USER_ID}+200]

if [` netstat -an | grep :${TOMCAT_PORT} | grep LISTEN | wc -l ` -eq 1 ]; then 
  echo "Port $[${USER_ID}+200] busy. Is your Tomcat-Webserver already running?"
  exit
fi

if [ ! -d ${TOMCAT_HOME}/webapps/${USER} ]; then
  mkdir ${TOMCAT_HOME}/webapps/${USER} 
  echo "Create user application directory ${TOMCAT_HOME}/webapps/${USER}"
fi
if [ ! -d ${TOMCAT_HOME}/work-${USER} ]; then
  mkdir ${TOMCAT_HOME}/work-${USER} 
  echo "Create ${TOMCAT_HOME}/work-${USER} as scratch directory"
fi

cd ${TOMCAT_HOME}/conf

BUILDFILE=${HOME}/path/to/cvs/for/example/build.xml
cat build-euromaxx.xml | sed \
        -e s#value=\"myapp\"#value=\"${USER}\"#g \
        > ${BUILDFILE}
chmod u+x ${BUILDFILE} 

# user-specific tomcat server config file (ports: first for HTTP, second for AJP)
cat server.xml | sed \
        -e s#logs/tomcat.log#logs/tomcat-${USER}.log#g \
        -e s#logs/servlet.log#logs/servlet-${USER}.log#g \
        -e s#logs/jasper.log#logs/jasper-${USER}.log#g \
        -e s#workDir=\"work\"#workDir=\"work-${USER}\"#g \
        -e s#value=\"8888\"#value=\"${TOMCAT_PORT}\"#g \
        -e s#value=\"8889\"#value=\"$[${USER_ID}+300]\"#g \
        -e s#path=\"/xy\"#path=\"\"#g \
        -e s#docBase=\"xy\"#docBase=\"${TOMCAT_HOME}/webapps/${USER}\"#g \
        > /var/tmp/server-${USER}.xml

cd ${TOMCAT_HOME}/bin
./tomcat.sh start -f /var/tmp/server-${USER}.xml

echo "### hello ${USER} ... "
echo "### your user app runs on" http://$HOSTNAME:${TOMCAT_PORT}/
-------------------------------------------------------------------------

bye, anke