Tomcat – Using Tomcat for development, qa and production deployments on the same box

tomcat

I'm working on a couple small/medium projects, but I do like tinkering with tools and I have to admit I do love overcomplicating things. The projects that I am working on are Java web applications that I have up until now deployed in a single Tomcat instance on a single server. My build tool of choice is Maven, source control; SVN, and I've got a Hudson and Bamboo CI server running.

Now, I'd like to have 3 "environments" if you will, that I will deploy my WARs to. I was thinking of having one for development builds (deployed on-demand via Hudson or nightly builds), QA to get feedback from friends, and production that I will hook up to my live domains.

How would I go about achieving this with Tomcat? I was thinking of running 3 different instances of Tomcat, with different priorities and memory pools assigned so that production would run smoothly but how exactly would I do that — create 3 run scripts (I want one "webapps" directory for each)?

I've got an 8-core Xeon with 8 GB RAM at my disposal and I do think it is sufficient for now, however, I am probably going to end up with using another server for production later on ;-). The box is running Gentoo. I also do not mind alternatives containers such as Resin being suggested.

Thanks in advance.

Best Answer

You got the idea. Use three tomcats and apache with mod_proxy_ajp in front of them for nice looking host names or even different domains.

Download tomcat from apache, and create 3 copies of the unpacked directory (I use /opt for this). Change ports in server.xml of two of them, add startup scripts (in case you need a reboot) and configure apache to serve all 3 from vhosts.

Additionally, you can use different jdk versions (for tests) downloading, unpacking and changing environment variables in tocmat scripts.

HTH