23
Getting Started with Capistrano and Ruby on Rails Slides taken from [email protected]

Getting Started with Capistrano

  • Upload
    rowena

  • View
    31

  • Download
    2

Embed Size (px)

DESCRIPTION

Getting Started with Capistrano. a nd Ruby on Rails. Slides taken from [email protected]. 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. - PowerPoint PPT Presentation

Citation preview

Page 1: Getting Started  with Capistrano

Getting Started with Capistrano

and Ruby on Rails

Slides taken from [email protected]

Page 2: Getting Started  with Capistrano

Automated App Deployment

using ssh

Page 3: Getting Started  with Capistrano

Not for server configurationUse Chef or Puppet for that

Page 4: Getting Started  with Capistrano

Installation$ gem install capistrano

Bundler:gem ‘capistrano’

Page 5: Getting Started  with Capistrano

Capify your application

$ capify .

Page 6: Getting Started  with Capistrano

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

Page 7: Getting Started  with Capistrano

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

Page 8: Getting Started  with Capistrano

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

Page 9: Getting Started  with Capistrano

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 end

end

Page 10: Getting Started  with Capistrano

Example Script (mongrel)

require 'mongrel_cluster/recipes'

namespace :deploy do task :restart do restart_mongrel_cluster endend

Page 11: Getting Started  with Capistrano

First-time server setup

$ cap deploy:setup

Page 12: Getting Started  with Capistrano

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

Page 13: Getting Started  with Capistrano

Deploy the app$ cap deploy

Page 14: Getting Started  with Capistrano

Deploy and run migrationscap deploy:migrations

Page 15: Getting Started  with Capistrano
Page 16: Getting Started  with Capistrano

Rollback to the last version$ cap rollback

Page 17: Getting Started  with Capistrano

Capistrano Best Practices

Page 18: Getting Started  with Capistrano

1. Create Deploy User$ sudo useradd deploy

(helps scope gems, config, logs, etc.)

Page 19: Getting Started  with Capistrano

2. Cleanup Old Deploys

$ cap cleanup

(leaves last 5 deploys, removes the rest)

Page 20: Getting Started  with Capistrano

3. Disable sudoconfig/deploy.rb:

:use_sudo false

Page 21: Getting Started  with Capistrano

4. Colorize Capistrano$ gem install capistrano_colors

In config/deploy.rb:require 'capistrano_colors'

Page 22: Getting Started  with Capistrano
Page 23: Getting Started  with Capistrano

Thank you