2

if I have several <Host> blocks in my server.xml like:

<Host name="www.mycompany.com" ...>
    <Alias>alias.com</Alias>
     ...
</Host>

what would be the best way to stop/start/restart just one one them ?

I was using /bin/Catalina.sh stop and /bin/Catalina.sh start when I had only a single host but now I want to be able to handle each of them without affecting the other ones.

How would that differ if I had several applications running on the same Host and I wanted to restart just one of the applications ?

epeleg
  • 215
  • 4
  • 13

2 Answers2

1

Set autoDeploy="true" in your Host container configuration and, in order to restart it, simply update the appBase or xmlBase content.

I use to run the command touch in Linux, just to update the war date or the host xml configuration. Example:

touch $CATALINA_BASE/conf/Catalina/www.mycompany.com/ROOT.xml

or

touch <appBase>/mycompany-app.war

Here's the documentation for the autoDeploy parameter:

autoDeploy This flag value indicates if Tomcat should check periodically for new or updated web applications while Tomcat is running. If true, Tomcat periodically checks the appBase and xmlBase directories and deploys any new web applications or context XML descriptors found. Updated web applications or context XML descriptors will trigger a reload of the web application. The flag's value defaults to true. See Automatic Application Deployment for more information.

1

I don't think you can. If you've got several hosts configured in your server.xml, they'll all be tied to the running tomcat container (JVM) and you'll have to restart the whole lot of them if you restart one.

It's been a while, but back in the day we had lots of individual instances running on our servers, and we used custom start/stop scripts to host individual apps and their associated configuration separately (at least those that should be separate).

This helped keep our deployments scoped to a single container, as well as our management actions. You may consider doing something similar in your case, particularly if you want to be able to manage them separately like this - on the surface it seems like it would make sense for you to do something similar.

mcauth
  • 420
  • 2
  • 5
  • But then who is listening on what port? AFAIK only one "engine" can listen on a specific port - an what if I want to have a.com an b.com both run independently (i.e. can be independently restarted/upgraded) on the same machine with both using port 80? – epeleg Dec 21 '11 at 11:57
  • We (obviously) had separate ports bound to each instance. Apache with name-based vhosts and mod_proxy setup can easily forward to the backend tomcat instances on their respective ports, per site. – mcauth Dec 21 '11 at 23:00