Getting Started with Capistrano
Upcoming SlideShare
Loading in...5
×
 

Getting Started with Capistrano

on

  • 1,726 views

Learn how to use Capistrano to automate the deployment of your Ruby on Rails applications. Apply best practices and add-ons for customizing Capistrano.

Learn how to use Capistrano to automate the deployment of your Ruby on Rails applications. Apply best practices and add-ons for customizing Capistrano.

Statistics

Views

Total Views
1,726
Views on SlideShare
1,726
Embed Views
0

Actions

Likes
7
Downloads
38
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Getting Started with Capistrano Getting Started with Capistrano Presentation Transcript

  • Getting Startedwith Capistrano and Ruby on Rails
  • Automated App Deployment using ssh
  • Not for serverconfigurationUse Chef or Puppet for that
  • Installation$ gem install capistrano Bundler: gem „capistrano‟
  • Capify your application $ capify .
  • Rails Directory Structure / |- public/ |- config/ - deploy.rb <--- Capistrano |- application/
  • Example Scriptset :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
  • Example Script (git)set :scm, :gitset :repository, “username@hostname:myapp.git”set :branch, “master”set :deploy_via, :remote_cache
  • Example Script (Passenger)namespace :deploy do desc "Restarting mod_rails with restart.txt” task :restart, :roles => :app, :except => { :no_release => true } do run "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 endend
  • Example Script (mongrel)require mongrel_cluster/recipesnamespace :deploy do task :restart do restart_mongrel_cluster endend
  • First-time server setup $ cap deploy:setup
  • :deploy_to/ |- releases/ - 201205041112 - 201206110904 |- current/ --> 201206110904
  • Deploy the app $ cap deploy
  • Deploy and run migrations cap deploy:migrations
  • Rollback to the last version $ cap rollback
  • Capistrano Best Practices
  • 1. Create Deploy User $ sudo useradd deploy (helps scope gems, config, logs, etc.)
  • 2. Cleanup Old Deploys $ cap cleanup (leaves last 5 deploys, removes the rest)
  • 3. Multi-Stage Deploy $ gem install capistrano-ext Bundler: gem „capistrano-ext‟
  • config/deploy.rb:set :stages, %w(production staging)set :default_stage, "staging”require capistrano/ext/multistage‟Add users for each stage:$ sudo useradd staging$ sudo useradd production
  • 4. Disable sudo config/deploy.rb: :use_sudo false
  • 5. Colorize Capistrano $ gem install capistrano_colors In config/deploy.rb: require capistrano_colors
  • Thank you @launchanyjames@launchany.com http://launchany.com