Deploying Java Applications with Capistrano 6

Posted by Ben Poweski Fri, 22 Feb 2008 12:01:00 GMT

Capistrano 2, the fantastic sequel to the already superb Rails deployment framework, is an excellent solution to the otherwise mundane task of deploying Java applications.

Network security restrictions prohibit me from using the typically SCM -> Production server configuration. Next, I ran into a few problems uploading Jar files using the put command. Luckily Alex Gorbatchev, posted an example of how to use SFTP within a Capistrano deployment recipe.

I used his idea and adapted my rails recipe using SFTP deployment.

namespace :deploy do                
  task :update_code do
    on_rollback { run "rm -rf #{release_path}" }
    run "mkdir #{release_path}" 
    files = Dir.glob('lib/*.jar') + Dir.glob('dist/*.jar')
    execute_on_servers(options) do |servers|
      servers.each do |server|
        files.each do |path|
          logger.info "uploading #{File.basename(path)} to #{server}"  
          sftp = sessions[server].sftp  
          sftp.connect unless sftp.state == :open  
          sftp.put_file path, File.join(current_path, File.basename(path))  
          logger.debug "done uploading #{File.basename(path)} to #{server}"  
        end
      end
    end    
    finalize_update
  end
end
Comments

Leave a comment

  1. krzyzowki about 3 years later:

    Thanks for this great post. Did you do it all on your own? This must’ve taken a lot of time

  2. pozycjonowanie about 3 years later:

    Great read You might want to follow up to this topic

  3. darmowe programy about 3 years later:

    I am not sure where you are getting your information, but great topic

  4. Welded wire mesh over 3 years later:

    the blog post is really the freshest on this noteworthy theme. I harmonize with your conclusions and will thirstily look forward to hear your coming updates. I will tell you something about useful Welded wire mesh,wire meshes and so on.

  5. Gert almost 4 years later:

    That’s an inenigous way of thinking about it.

  6. hgeshzcowv almost 4 years later:

    qxnGsD xzikgztfrzgu

Comments