Deploying Rails applications with


 Capistrano




             http://www.flickr.com/photos/jsome1/2226394415
What is Capistrano?




                      http://www.flickr.com/photos/dionisio/2481071707
requirements




Ruby + Rake   SCM      SSH
installation



$ gem install capistrano
assumptions

●
    We are using SSH. Telnet and FTP are not
    supported
●
    Servers have POSIX-compatible shell

●
    SSH Keys configured
capification


$ cd my_app
$ cap .


/my_app
| - Capifile
| - /config/deploy.rb
1/2
                        configuration

set :application, “siege”
set :repository, “git@github.com:m3nd3s/siege.git”
set :scm, :git
set :branch, “master”
set :ssh_options, { :forward_agent => true }
set :user, “giran”
set :deploy_to, “/home/giran/siege”
set :my_var, “Giran Siege”

                                        config/deploy.rb
2/2
                  configuration


role :web, “siege.giran.com.br”
role :app, “siege.giran.com.br”
role :db, “siege.giran.com.br”
tasks

task :acceptance do
 set :user, "root"
 set :deploy_to, "/var/www/siege"
end
setting up

$ cap deploy:setup


# Or cascaded tasks


$ cap acceptance deploy:setup
structure

[deploy_to]
[deploy_to]/releases
[deploy_to]/shared
[deploy_to]/shared/log
[deploy_to]/shared/pids
[deploy_to]/shared/system
database

  ●
      Database needs to be created


namespace :deploy do
  task :database, :roles => :app do
    run "cp #{deploy_to}/shared/database.yml
#{current_path}/config/"
  end
end
deploy

$ cap deploy


# Or cascaded tasks


$ cap acceptance deploy
after and before

after :deploy, 'deploy:database'
namespace :deploy do
      ...
end
restart

namespace :deploy do
  task :restart, :roles => :app, :except => {
:no_release => true } do
          run "cd #{current_path} && touch
      tmp/restart.txt"
        end
end
http://www.flickr.com/photos/mpawl/1572150843
references



https://github.com/capistrano/capistrano/wiki/_pages
thank you !




        Almir 'm3nd3s'
          @m3nd3s
http://www.almirmendes.com
 almir.mendes@giran.com.br
     m3nd3s@gmail.com

       http://www.flickr.com/photos/meepfriends/2279161806

Deploying Rails Applications with Capistrano