Deployment and Continuous Integration From the Trenches

by Fernand Galiana

Capistrano 2.0
- namespaces
- deployment strategies
- events framework
- run/sudo commands
- online help

Fernand reality:
- 10 internal applications
- 4 "public" applications

typical configuration:
- apache 
- mongrel cluster
- (n mongrels)
- monit
- HAProxy
- DB (+ DB ro)

installing/starting to use capistrano:
- gem install capistrano
- cd <project>
- capify .

cap deploy
    - creates special dirs:
        releases
        shared
    - deploy.rb
    - moves source code into a release 
    - source control

    - deploy:setup
    lays down deployment dir on remote hosts
        set :application 'fred'
        set :deploy_to <remote_dir>
    ...

capistrano isn't rails, you can use it for any app
    - my_cap.rb - configuration file

events
    - do something before/after something
    - chain filters
        before task1, task2 etc..

        def :task1 do
            ....
        end

    - inline
        after :task1
            ...
        end

variables and bindings

multistage extension (multistage-ext)
    - allow to define "stages" for each different machine/environment you might have
        . development 
        . staging 
        . production
    - careful about using cross-reference definition of variables..
        var_1 = "xxx #{var_2}"  < -- trouble!!!

Capfile
    - one for all the applications
    - load it before anything else
        . load "../Capfile"

Conclusion
    - multistage-ext (MUST!)
    - use remote cache (if you can)
    - make sure you o code locally
    - public keys (if you wish to live longer)
    - dry up your configs
    - roll your own tasks
        . recipes.rb
        . require 'cap/mailer/recipes'

capote
    - rails app to manage your rails deployment
    - sits on top of your capistrano files

REFERENCEs

    Jamis buck blog
        http://weblog.jamisbuck.org
    Capistrano forum
        http://groups.google.com/group/capistrano
    Webistrano
        http:/blog.innerewut.de/webistrano
    Capote
        http://liquidrails.com