SlideShare a Scribd company logo
Getting Started
with Capistrano
   and Ruby on Rails
Automated App
 Deployment
    using ssh
Not for server
configuration
Use 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 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
Example Script (git)
set :scm, :git
set :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
 end

end
Example Script (mongrel)
require 'mongrel_cluster/recipes'


namespace :deploy do
 task :restart do
   restart_mongrel_cluster
 end
end
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
Getting Started with Capistrano
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'
Getting Started with Capistrano
Thank you
      @launchany
james@launchany.com
  http://launchany.com

More Related Content

PPTX
Capistrano - automate all the things
PPT
Capistrano
PPT
Capistrano - Deployment Tool
PPTX
Deployment with capistrano
PPTX
Control your deployments with Capistrano
PPTX
Capistrano 3 Deployment
PDF
Infrastructure = code - 1 year later
PDF
Background processing with Resque
Capistrano - automate all the things
Capistrano
Capistrano - Deployment Tool
Deployment with capistrano
Control your deployments with Capistrano
Capistrano 3 Deployment
Infrastructure = code - 1 year later
Background processing with Resque

What's hot (20)

PPTX
Ansible intro
PPT
Capistrano Overview
KEY
GPerf Using Jesque
KEY
Background Jobs with Resque
PPT
Capistrano
PDF
Designing net-aws-glacier
KEY
Capistrano, Puppet, and Chef
KEY
Php resque
PDF
Capistrano 2 Rocks My World
PPTX
Toolbox of a Ruby Team
PDF
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
PDF
Selenium sandwich-3: Being where you aren't.
PDF
V2 and beyond
PDF
What's New in v2 - AnsibleFest London 2015
PDF
Modern Perl Toolchain
PDF
The Puppet Master on the JVM - PuppetConf 2014
PDF
Deploying Rails Applications with Capistrano
PDF
How to contribute Apache CloudStack
PPTX
Where is my scalable api?
Ansible intro
Capistrano Overview
GPerf Using Jesque
Background Jobs with Resque
Capistrano
Designing net-aws-glacier
Capistrano, Puppet, and Chef
Php resque
Capistrano 2 Rocks My World
Toolbox of a Ruby Team
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Selenium sandwich-3: Being where you aren't.
V2 and beyond
What's New in v2 - AnsibleFest London 2015
Modern Perl Toolchain
The Puppet Master on the JVM - PuppetConf 2014
Deploying Rails Applications with Capistrano
How to contribute Apache CloudStack
Where is my scalable api?
Ad

Similar to Getting Started with Capistrano (20)

KEY
Railsconf2011 deployment tips_for_slideshare
PDF
Burn down the silos! Helping dev and ops gel on high availability websites
PDF
Practical Chef and Capistrano for Your Rails App
PDF
Perl web frameworks
PDF
Curscatalyst
PDF
Silex Cheat Sheet
PDF
Silex Cheat Sheet
PDF
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
PPTX
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
PPTX
Rails Engine | Modular application
ODP
Capifony. Minsk PHP MeetUp #11
PDF
Doctrine For Beginners
PDF
PDF
Generators
KEY
Api Design
KEY
Quality Use Of Plugin
PDF
2023 - Drupalcon - How Drupal builds your pages
PDF
Drupalcon 2023 - How Drupal builds your pages.pdf
PDF
Background Jobs - Com BackgrounDRb
PDF
Painless Deployment with Capistrano
Railsconf2011 deployment tips_for_slideshare
Burn down the silos! Helping dev and ops gel on high availability websites
Practical Chef and Capistrano for Your Rails App
Perl web frameworks
Curscatalyst
Silex Cheat Sheet
Silex Cheat Sheet
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
Rails Engine | Modular application
Capifony. Minsk PHP MeetUp #11
Doctrine For Beginners
Generators
Api Design
Quality Use Of Plugin
2023 - Drupalcon - How Drupal builds your pages
Drupalcon 2023 - How Drupal builds your pages.pdf
Background Jobs - Com BackgrounDRb
Painless Deployment with Capistrano
Ad

More from LaunchAny (20)

PPTX
Refining Your API Design - Architecture and Modeling Learning Event
PPTX
Event-Based API Patterns and Practices
PDF
Event-based API Patterns and Practices - AsyncAPI Online Conference
PDF
GlueCon 2019: Beyond REST - Moving to Event-Based APIs and Streaming
PDF
Austin API Summit 2019 - APIs, Microservices, and Serverless: The Shape of Th...
PDF
APIStrat Keynote: Lessons in Transforming the Enterprise to an API Platform
PPTX
Austin API Summit 2018: Are REST APIs Still Relevant Today?
PDF
GlueCon 2018: Are REST APIs Still Relevant Today?
PPTX
Lessons in Transforming the Enterprise to an API Platform
PPTX
APIStrat 2017: API Design in the Age of Bots, IoT, and Voice
PDF
API Design in the Age of Bots, IoT, and Voice
PDF
APIStrat 2016: Moving Toward a Modular Enterprise
PDF
API:World 2016 - Applying Domain Driven Design to APIs and Microservices
PPTX
Moving Toward a Modular Enterprise - All About the API Conference 2016
PPTX
Designing APIs and Microservices Using Domain-Driven Design
PPTX
Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup
PDF
APIs Are Forever - How to Design Long-Lasting APIs
PDF
API Thinking - How to Design APIs Through Systems Design
PDF
Swagger 2.0: Latest and Greatest
PDF
Gluecon 2015 Recap
Refining Your API Design - Architecture and Modeling Learning Event
Event-Based API Patterns and Practices
Event-based API Patterns and Practices - AsyncAPI Online Conference
GlueCon 2019: Beyond REST - Moving to Event-Based APIs and Streaming
Austin API Summit 2019 - APIs, Microservices, and Serverless: The Shape of Th...
APIStrat Keynote: Lessons in Transforming the Enterprise to an API Platform
Austin API Summit 2018: Are REST APIs Still Relevant Today?
GlueCon 2018: Are REST APIs Still Relevant Today?
Lessons in Transforming the Enterprise to an API Platform
APIStrat 2017: API Design in the Age of Bots, IoT, and Voice
API Design in the Age of Bots, IoT, and Voice
APIStrat 2016: Moving Toward a Modular Enterprise
API:World 2016 - Applying Domain Driven Design to APIs and Microservices
Moving Toward a Modular Enterprise - All About the API Conference 2016
Designing APIs and Microservices Using Domain-Driven Design
Applying Domain-Driven Design to APIs and Microservices - Austin API Meetup
APIs Are Forever - How to Design Long-Lasting APIs
API Thinking - How to Design APIs Through Systems Design
Swagger 2.0: Latest and Greatest
Gluecon 2015 Recap

Recently uploaded (20)

PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Electronic commerce courselecture one. Pdf
PDF
KodekX | Application Modernization Development
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
cuic standard and advanced reporting.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Network Security Unit 5.pdf for BCA BBA.
NewMind AI Weekly Chronicles - August'25 Week I
Understanding_Digital_Forensics_Presentation.pptx
Spectral efficient network and resource selection model in 5G networks
Diabetes mellitus diagnosis method based random forest with bat algorithm
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Digital-Transformation-Roadmap-for-Companies.pptx
MIND Revenue Release Quarter 2 2025 Press Release
sap open course for s4hana steps from ECC to s4
Electronic commerce courselecture one. Pdf
KodekX | Application Modernization Development
Building Integrated photovoltaic BIPV_UPV.pdf
cuic standard and advanced reporting.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Encapsulation_ Review paper, used for researhc scholars
The Rise and Fall of 3GPP – Time for a Sabbatical?
Profit Center Accounting in SAP S/4HANA, S4F28 Col11

Getting Started with Capistrano