views:

169

answers:

4

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?

A: 

All I know is that you can change a groovy file or a .gsp one and after you save the changes are available in the browser, but if there are other types of files I am not exactly sure of this feature.

Bobby
+1  A: 

Once your app is packaged as a WAR, changes to the source files won't be propagated automatically like you get using run-app. In general I think that particularly for compiled code with code that's effectively live all the time, it's a bit risky to perform live updates. You can cope with the odd deployment glitch during development, but in production I'd rather play it safe and live with a little bit of downtime.

dogbert
+1  A: 

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.

cheers

Lee

leebutts
Yeah, this definitely seems to be the way to go. Thanks.
Thody
+2  A: 

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.

Stefan