1 / 23

Getting Started with Capistrano

Getting Started with Capistrano. a nd Ruby on Rails. Slides taken from james@launchany.com. Automated App Deployment. u sing ssh. Not for server configuration. Use Chef or Puppet for that. Installation. $ gem install capistrano Bundler: gem ‘ capistrano ’. Capify your application.

rowena
Télécharger la présentation

Getting Started with Capistrano

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Getting Started with Capistrano and Ruby on Rails Slides taken from james@launchany.com

  2. Automated App Deployment using ssh

  3. Not for server configuration Use Chef or Puppet for that

  4. Installation $ gem install capistrano Bundler: gem ‘capistrano’

  5. Capify your application $ capify .

  6. Rails Directory Structure / |- public/ |- config/ - deploy.rb <--- Capistrano |- application/

  7. Example Script set :application, "set your application name here”role :app, "your app-server here”role :web, "your web-server here”role :db, "your db-server here", :primary => true

  8. Example Script (git) set :scm, :gitset :repository, “username@hostname:myapp.git”set :branch, “master”set :deploy_via, :remote_cache

  9. Example Script (Passenger) namespace :deploy dodesc"Restarting mod_rails with restart.txt”task :restart, :roles => :app, :except => { :no_release => true } dorun "touch #{current_path}/tmp/restart.txt” end [:start, :stop].each do |t|desc "#{t} task is a no-op with mod_rails”task t, :roles => :app do ; end end end

  10. Example Script (mongrel) require 'mongrel_cluster/recipes' namespace :deploy dotask :restart dorestart_mongrel_cluster endend

  11. First-time server setup $ cap deploy:setup

  12. :deploy_to/ |- releases/ - 201205041112 - 201206110904 |- current/ --> 201206110904

  13. Deploy the app $ cap deploy

  14. Deploy and run migrations cap deploy:migrations

  15. Rollback to the last version $ cap rollback

  16. Capistrano Best Practices

  17. 1. Create Deploy User $ sudouseradd deploy (helps scope gems, config, logs, etc.)

  18. 2. Cleanup Old Deploys $ cap cleanup (leaves last 5 deploys, removes the rest)

  19. 3. Disable sudo config/deploy.rb: :use_sudofalse

  20. 4. Colorize Capistrano $ gem install capistrano_colors In config/deploy.rb: require 'capistrano_colors'

  21. Thank you

More Related