Capistrano

826 views

Published on

Presentation given to the April 2010 Ruby on Rails Meetup group.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
826
On SlideShare
0
From Embeds
0
Number of Embeds
15
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Capistrano

  1. 1. Capistrano
  2. 2. Prerequisites <ul><li>SSH access to server </li></ul><ul><li>SSH user/password (ssh keys are better) </li></ul><ul><li>Ruby </li></ul>
  3. 3. <ul><ul><li>Step 1: Cut a hole in the box </li></ul></ul><ul><ul><li>gem install capistrano </li></ul></ul><ul><ul><li>Step 2: cd path/to/project </li></ul></ul><ul><ul><li>Step 3: capify . </li></ul></ul>Project Setup
  4. 4. Customize config.rb <ul><li>Required settings </li></ul>set :application , &quot;test_app&quot; set :domain , &quot;mysite.com&quot; set :deploy_to , &quot;/var/www/apps/#{application}&quot; set :repository , &quot; http://svn.centresource.com/#{application}/trunk &quot; role :web , domain # where the web server runs role :app , domain # where the application layer runs role :db , domain, :primary => true # where your db runs
  5. 5. Customize config.rb <ul><li>Optional settings </li></ul>set :scm , :git set :repository , &quot; [email_address] :username/projectname.git&quot; set :user , &quot;deploy&quot; set :password , &quot;p@55w0rd&quot; set :use_sudo , false <ul><li>Recommended settings </li></ul>set :deploy_via , 'remote_cache' set :keep_releases , 5
  6. 6. Folder Structure <ul><li>Folder structure on server (created by calling cap servers:setup ) </li></ul>/deploy_to_path --current (symlink) --releases --20100422123598 --20100422123942 --shared --system --pids --logs
  7. 7. The Process <ul><li>Container (does nothing) </li></ul><ul><li>Container (does nothing) </li></ul><ul><li>Copies code to server </li></ul><ul><li>Touches up the copied code </li></ul><ul><li>Updates current symlink </li></ul><ul><li>Restarts application </li></ul>
  8. 8. Custom Tasks # symlink database namespace :deploy do desc &quot;Symlink database.&quot; task :symlink_db do run &quot;ln -nfs #{shared_path}/system/database.yml #{release_path}/config/database.yml&quot; end end after 'deploy:update_code' , 'deploy:symlink_db'
  9. 9. Overwrite Tasks namespace :deploy do # symfony doesn't need these tasks task :start do ; end task :stop do ; end task :restart do ; end # doctrine migration task :migrate do run &quot;cd #{release_path} && php symfony doctrine:migrate --env='prod'&quot; end end
  10. 10. Put It All Together <ul><li>cap servers:setup </li></ul><ul><li>cap deploy:cold </li></ul><ul><li>cap deploy </li></ul><ul><li>cap deploy:migrations </li></ul><ul><li>cap deploy:rollback </li></ul><ul><li>cap -T </li></ul>
  11. 11. Questions?

×