I've been using Tomcat 8's Parallel Deployment as part of a zero-downtime continuous deployment setup for a while now.
When the test gauntlet has been run, the CI server automatically renames the .war file to application##{version-number}.war and copies the war to the /webapp folder. application##333 will coexist nicely with application##332.
The only problem that I'm encountering is that I have to manually undeploy the older applications once all traffic (new sessions) have automatically transitioned to the new one.
Does Tomcat have some built-in mechanism for saying "hey, when this service gets down to zero sessions, it should be removed"? Maybe some sort of "the last session has just expired" event that I can tap into.
If anyone else has automated this kind of application undeploy, I would love to hear about it. Thanks!
Best Answer
You can configure Tomcat to remove the old applications. You need to add the
undeployOldVersions
attribute to theHost
element and set it totrue
. You'll need to modify your host in server.xml to something like the following:See the Host documentation for details. In particular, this only works when automatic deployment is enabled.