I am using *Capistrano 2.15.5* to deploy *Java *web applications to *Tomcat* 
application servers. For the time being, we are tied and committed to this 
version of Capistrano and we cannot upgrade to v3. The deploy task will 
call on the other tasks to get executed in parallel on all servers in the 
role. This works as expected and has been working well for a while. 

Now we need to implement a *Rolling Deployment* when the tasks are executed 
on one server at a time. So, based on the code below, we would execute 
shutdown_tomcat, 
download_bits, deploy_bits, start_tomcat on prdapp01 first and then prdapp02 
and 
so on... So that only one server in the cluster is offline at any given 
time, thus maximizing our up-time. 

What is the best way to implement this *Rolling Deployment* strategy with 
Capistrano? 

This is what a paired-down version of my Capistrano script looks like 
currently:

    task :production do
      role :app,   "deployuser@prdapp01", "deployuser@prdapp02", 
"deployuser@prdapp03"
      # ...
    end
    
    task :deploy do
      shutdown_tomcat
      download_bits
      deploy_bits
      start_tomcat
    end
    
    task :shutdown_tomcat, :roles => :app do
      run "sudo /sbin/service tomcat stop || exit 1;"
    end
    
    task :download_bits, :roles => :app do
      run <<-EOS
        [ -f /tmp/app_download ] && rm -rf /tmp/app_download;
        mkdir -p /tmp/app_download;
        cd /tmp/app_download;
        wget -q https://internal.server/path/to/application.war || exit 1;
      EOS
    end
    
    task :deploy_bits, :roles => :app do
      run <<-EOS
        cd /tmp/app_download;
        unzip -q -o /tmp/app_download/application.war -d /usr/local/tomcat/
webapps/ || exit 1;
        exit 0;
      EOS
    end
    
    task :start_tomcat, :roles => :app do
      run "sudo /sbin/service tomcat start || exit 1;"
    end


Then I run ...

    $ cap -f deploy.cap production deploy

-- 
You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to capistrano+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/capistrano/a4f52334-aee9-4c09-94ba-247cebe6ca27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to