Dave Shevett wrote:
Hey folks - I've gotten great help on the list before, I'm looking for some guidance on how to approach this...

I have a hosted service that deploys / provisions vhosts running a prepackaged .war app. I'd like to be able to 'spin up' a vhost on the fly, without restarting tomcat.

What I'm doing now is:
* Create a directory in /etc/tomcat6/Catalina/vhostname/
* Create a ROOT.xml in that dir that has <Context docBase=[sharedwarfilename]...> for the vhost
* Edit server.xml to make a new Host entry
* Restart tomcat

The app goes live (there's an Apache httpd front end with a wildcard on the domain that's using ajp: connections to Tomcat, so foo.domainname.com will look for a vhost of that name on the Tomcat server).

This works, but is a pain because it requires a tomcat restart and a manual file edit.

What I want to do be able to do is bring up a vhost, maybe via the Tomcat manager, without doing a restart. I can deploy a .war file easy, but the vhost entry wouldn't wake up.

My understanding is I can make the vhosts go active via a script or tool that uses JMX calls to Tomcat to configure up the vhost, but my understanding is this configuration is mutable - if Tomcat restarts, all the vhost configurations disappear, and I have to 'reprovision it'.

Is it possible to spin up and down vhosts like this without restarting tomcat, and if so, what's the preferred methodology that makes it reproduceable, if the configuration is only in memory, and will disappear if/when tomcat restarts?


I read somewhere that there exists an old African proverb which says : if you want to eat an elephant, you have to do it one little piece at a time.

It seems that you have already most of the parts done, and are just missing the "persistent" part of the <Host> entries in server.xml. It would seem like a fairly easy task, with a bit of scripting, to have a template server.xml with some kind of an "include" tag (à la <!-- here come the Hosts -->), and whenever you create a new Host dynamically, adding it to some table, and rewriting the server.xml with the appropriate <Host> entries inserted in the template.
This way, whenever you restart Tomcat, it would "remember" these Hosts.
The script to re-create the server.xml could be inserted in your Tomcat startup 
mechanism.

Not discounting the other excellent and more elaborate suggestions received on the list, you may want to have a look at such a simple alternative.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to