Capistrano 2 Rocks My World

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Capistrano 2 Rocks My World - Presentation Transcript

    1. Capistrano 2 Rocks my world Graeme Mathieson, Rubaidh Ltd <mathie@rubaidh.com> http://woss.name/ & http://www.rubaidh.com/
    2. What’s the plan? • So, what is it? • Installing 2.0 • What’s new in Cap 2? • Stuff I’ve done with cap 2
    3. What is it? • A Rails deployment tool • A Java deployment tool • A troubleshooting tool • An ad-hoc systems management tool
    4. Without a Capfile $ cap2 invoke COMMAND=uname HOSTS=macallan,cardhu * executing `invoke' * executing \"uname\" servers: [\"macallan\", \"cardhu\"] [macallan] executing command [cardhu] executing command ** [out :: cardhu] SunOS ** [out :: macallan] Linux command finished $
    5. Using cap shell $ cap2 shell HOSTS=balvenie,cardhu * executing `shell' cap> uptime [establishing connection(s) to balvenie, cardhu] ** [out :: balvenie] 19:33:52 up 211 days, 7:25, 1 user, load average: 0.06, 0.07, 0.07 ** [out :: cardhu] 7:33pm up 10 day(s), 6:47, 2 users, load average: 0.18, 0.16, 0.15 cap> uname -r ** [out :: balvenie] 2.4.21-47.0.1.EL ** [out :: cardhu] 5.10 cap>
    6. Installing 2.0 $ gem install -y net-ssh net-ftp highline [ ... ] $ gem install -s http://gems.rubyonrails.com/ capistrano [ ... ] Done!
    7. Co-existing with 1.x # In ~/.bashrc alias cap1=\"`which cap` _1.4.1_\" alias cap2=\"`which cap`\" alias cap=\"echo 'Please explicitly choose cap1 or cap2.'\"
    8. New in 2.0? • More rake-like - Use `cap2 -T` to list tasks - Namespaces • Deployment strategies • Dependencies • Generic hooks
    9. New task names • deploy well, umm, deploy • deploy_with_migrations deploy:migrations • diff_from_last_deploy deploy:pending:diff • setup deploy:setup • Same idea, just with namespaces
    10. New Deployment Tasks • Subversion log of undeployed changes • deploy:pending • Command, gem, file, directory dependencies • deploy:check
    11. What I’ve been up to
    12. Recipes in plugins # New Capfile Dir['vendor/plugins/*/recipes'].each do |plugin| load_paths << plugin end load 'deploy' if respond_to?(:namespace) load 'config/deploy'
    13. Daemon Strategies • Default uses spin/spawner/reaper • Solaris Service Management Framework • runit • daemontools • Autogenerate script/spin
    14. Staging • Separate clusters for staging & deployment • Use svnmerge to manage branches • Trunk is deployed to staging server • Production branch gets deployed live
    15. General Strategy • Create a rake task to do what you want. • Create a Capistrano task that runs the rake task. • Hook it into the deployment.
    16. DB Backup - Rake desc \"Dumps the database into db/env-data.sql.\" task :dump => :environment do abc = ActiveRecord::Base.configurations[RAILS_ENV] cmd = ['mysqldump'] cmd << \"--host='#{abc['host']}'\" unless abc['host'].blank? cmd << \"--user='#{abc['username']}'\" cmd << \"--password='#{abc['password']}'\" cmd << abc['database'] cmd << \" | gzip > #{RAILS_ROOT}/db/#{RAILS_ENV}-data.sql.gz\" sh cmd.flatten.join ' ' end
    17. DB Backup - Capfile desc “Back up the production database” task :backup, :roles => :db, :only => { :primary => true } do rake = fetch(:rake, 'rake') rails_env = fetch(:rails_env, 'production') run \"cd #{current_path}; #{rake} RAILS_ENV=#{rails_env} db:dump\" get \"#{current_path}/db/#{rails_env}-data.sql.gz\", \"db/# {rails_env}-data.sql.gz\" end
    18. Hook into deployment before \"deploy:migrate\", \"db:backup\"
    19. All in a plugin $ script/plugin install -x \\ http://svn.rubaidh.com/plugins/trunk/rubaidh_platform
    20. “I checked out your slides, and they look great! Best of luck on your presentation.” - Jamis Buck
    21. What else do you want to know?

    + mathiemathie, 3 years ago

    custom

    2840 views, 1 favs, 1 embeds more stats

    The talk I gave at ScotRUG last night about Capistr more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 2840
      • 2831 on SlideShare
      • 9 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 75
    Most viewed embeds
    • 9 views on http://blog.impactmedia.com.br

    more

    All embeds
    • 9 views on http://blog.impactmedia.com.br

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories