开发者

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

开发者 https://www.devze.com 2022-12-10 21:14 出处:网络
Hey, I\'m new to Grails, and I\'m wondering about deployment. Once a .war is deployed to produ开发者_如何学Cction, how can I update the application without downtime?You might setup two tomcat instance

Hey, I'm new to Grails, and I'm wondering about deployment. Once a .war is deployed to produ开发者_如何学Cction, how can I update the application without downtime?


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.


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


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消