Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Capistrano Overview


Published on

  • Be the first to comment

  • Be the first to like this

Capistrano Overview

  1. 1. Capistrano <ul><li>Travis Roberts </li></ul><ul><li>[email_address] </li></ul><ul><li> </li></ul>
  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 deploy.rb <ul><li>Required settings </li></ul>set :application , &quot;test_app&quot; set :domain , &quot;; set :deploy_to , &quot;/var/www/apps/#{application}&quot; set :repository , &quot;{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 deploy.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>