Download presentation
Presentation is loading. Please wait.
Published byLauren Yarbough Modified over 9 years ago
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/ |- public/ |- config/ |- config/ - deploy.rb <--- Capistrano - deploy.rb <--- Capistrano |- application/ |- 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, set, “ set, set, set :scm, :git set :repository, “username@hostname:myapp.git” set :branch, “master” set :deploy_via, :remote_cache
9
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 [:start, :stop].each do |t| desc "#{t} task is a no-op with mod_rails” task t, :roles => :app do ; end endend
10
Example Script (mongrel) require 'mongrel_cluster/recipes' namespace :deploy do task :restart do restart_mongrel_cluster end end
11
First-time server setup $ cap deploy:setup
12
:deploy_to/ |- releases/ |- releases/ - 201205041112 - 201205041112 - 201206110904 - 201206110904 |- current/ --> 201206110904 |- current/ --> 201206110904
13
Deploy the app $ cap deploy
14
Deploy and run migrations cap deploy:migrations
16
Rollback to the last version $ cap rollback
17
Capistrano Best Practices
18
1. Create Deploy User $ sudo useradd deploy (helps scope gems, config, logs, etc.)
19
2. Cleanup Old Deploys $ cap cleanup (leaves last 5 deploys, removes the rest)
20
3. Disable sudo config/deploy.rb: :use_sudo false
21
4. Colorize Capistrano $ gem install capistrano_colors In config/deploy.rb: require 'capistrano_colors'
23
Thank you
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.