Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to deploy a new .war application without stopping the application?

Tags:

grails

tomcat

war

Hey, I'm new to Grails, and I'm wondering about deployment. Once a .war is deployed to production, how can I update the application without downtime?

like image 927
Thody Avatar asked Nov 02 '09 21:11

Thody


3 Answers

You might setup two tomcat instances with an Apache mod_proxy_balancer in front of it, as described here. For a redeployment of the application a "rolling upgrade" strategy might be applied (assuming app1 and app2 are your two tomcat instances):

  1. Disable tomcat@app1 in Apache's balancer-manager
  2. Redeploy application to tomcat@app1
  3. Do some testing with app1 and see if everything works
  4. Enable tomcat@app1 in balancer-manager
  5. Disable tomcat@app2 in balancer-manager
  6. Redeploy application to tomcat@app2
  7. Enable tomcat@app2 in balancer-manager

And you're done. You don't need multiple physical or virtual machines for doing so - it's also possible on a single box. If your application upgrade implies database changes, be careful. The above might be encapsulated e.g. in an gant script, so a simple "grails cluster-redeploy" does everything you need. Such a script is currently on my list, but I have no idea when this will be finished.

like image 165
Stefan Armbruster Avatar answered Nov 15 '22 09:11

Stefan Armbruster


If you're using Tomcat, it's possible, with what's called Parallel Deployment:

http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Parallel_deployment

Simply name the war files with the version number as described in the doc:

  • foo##42.war
  • foo##43.war
like image 35
djKianoosh Avatar answered Nov 15 '22 08:11

djKianoosh


Even if you hot deploy the WAR file (by not restarting the server) there will still be some downtime while the context reloads. This isn't a Grails thing as such, more of a J2EE/servlet thing.

As dogbert said, best to put up a maintenance page (using Apache in front of Tomcat is a good idea) and shut down the app server, upload the new WAR then start the server up again.

like image 25
leebutts Avatar answered Nov 15 '22 08:11

leebutts