SlideShare a Scribd company logo
1 of 31
Download to read offline
Capistrano 2
Beyond Hassle-Free Deployment
          Luca Mearelli
       Pisa - Oct. 27, 2007
Rails is fun
Rails is fun
Rails is TOO MUCH fun
Deployment
System Administration
Rails : Web development
              =
Capistrano : Sys.administration
Capistrano basics

•SSH to the remote machines
•Posix compatible shell
•Same password or public key
•a bit of ruby knowledge
•works from a command line
Capistrano basics

•Capfile (makefile, rakefile, ...)
•It’s ruby
 task :dump_db, :hosts => quot;database.spazidigitali.comquot; do
   run quot;mysqldump -u deploy sd_production > /home/luca/dumps/db.sqlquot;
 end



  cap dump_db
role :sd_db, quot;database.spazidigitali.comquot;

task :dump_db do
  run quot;mysqldump -u deploy sd_production > /home/luca/dumps/db.sqlquot;
end

task :free_space do
  run quot;df -hquot;
end




       cap dump_db
set :gateway, quot;firewall.spazidigitali.comquot;
role :sd_db, quot;database.spazidigitali.comquot;

task :dump_db do
  run quot;mysqldump -u deploy sd_production > /home/luca/dumps/db.sqlquot;
end

task :free_space do
  run quot;df -hquot;
end




       cap dump_db
set :gateway, quot;firewall.spazidigitali.comquot;
role :sd_db, quot;database.spazidigitali.comquot;, quot;replica.spazidigitali.comquot;

task :dump_db do
  run quot;mysqldump -u deploy sd_production > /home/luca/dumps/db.sqlquot;
end

task :free_space do
  run quot;df -hquot;
end




       cap dump_db
set :gateway, quot;firewall.spazidigitali.comquot;
role :sd_db, quot;database.spazidigitali.comquot;, quot;replica.spazidigitali.comquot;
role :sd_app, quot;mongrels.spazidigitali.comquot;

task :dump_db, :roles=>:sd_db do
  run quot;mysqldump -u deploy sd_production > /home/luca/dumps/db.sqlquot;
end

task :free_space, :roles=>[:sd_db, :sd_app ] do
  run quot;df -hquot;
end




       cap dump_db
set :gateway, quot;firewall.spazidigitali.comquot;
role :sd_db, quot;database.spazidigitali.comquot;, quot;replica.spazidigitali.comquot;
role :sd_app, quot;mongrels.spazidigitali.comquot;

namespace :spazidig do
  desc quot;Dumping our DBsquot;
  task :dump_db, :roles=>:sd_db do
    run quot;mysqldump -u deploy sd_production > /home/luca/dumps/db.sqlquot;
  end

  desc quot;Checking free spacequot;
  task :free_space, :roles=>[:sd_db, :sd_app ]do
    run quot;df -hquot;
  end
end




       cap spazidig:dump_db
set :gateway, quot;firewall.spazidigitali.comquot;
role :sd_db, quot;database.spazidigitali.comquot;, quot;replica.spazidigitali.comquot;
role :sd_app, quot;mongrels.spazidigitali.comquot;

namespace :spazidig do
  desc quot;What??quot;
  task :default do
    run quot;uname -aquot;
  end

 desc quot;Dumping our DBsquot;
 task :dump_db, :roles=>:sd_db do
   run quot;mysqldump -u deploy sd_production > /home/luca/dumps/db.sqlquot;
 end

  desc quot;Checking free spacequot;
  task :free_space, :roles=>[:sd_db, :sd_app ]do
    run quot;df -hquot;
  end
end


       cap spazidig
           spazidig:dump_db
       cap dump_db
       cap spazidig:free_space
set :gateway, quot;firewall.spazidigitali.comquot;
role :sd_db, quot;database.spazidigitali.comquot;, quot;replica.spazidigitali.comquot;
role :sd_app, quot;mongrels.spazidigitali.comquot;

set :destination, quot;db.sqlquot;

namespace :spazidig do
  desc quot;Dumping our DBsquot;
  task :dump_db, :roles=>:sd_db do
    run quot;mysqldump -u deploy sd_production > /home/luca/dumps/#{destination}.sqlquot;
  end
end




        cap spazidig:dump_db
set :gateway, quot;firewall.spazidigitali.comquot;
role :sd_db, quot;database.spazidigitali.comquot;, quot;replica.spazidigitali.comquot;
role :sd_app, quot;mongrels.spazidigitali.comquot;

set :destination, quot;db.sqlquot;

set(:database) do
  Capistrano::CLI.ui.ask quot;Which database?: quot;
end

namespace :spazidig do
  desc quot;Dumping our DBsquot;
  task :dump_db, :roles=>:sd_db do
    run quot;mysqldump -u deploy #{database} > /home/luca/dumps/#{destination}.sqlquot;
  end
end




        cap spazidig:dump_db
task :deploy do
  transaction do
    try_this
    then_do_that

  end
end

task :try_this do
  on_rollback { run quot;do_cleanupquot; }
  #...
end

task :then_do_that do
  on_rollback { run quot;do_super_cleanupquot; }
  #...
end
on :event, :callback, :only => %w(tasks_to_do)
# :load, :exit, :start, :finish, :begin, :after


trigger :notify, current_task

on :notify, :callback
load_paths << quot;config/deployquot;
case ENV['STAGE']
when quot;productionquot; then
  load quot;productionquot;
when quot;stagingquot; then
  load quot;stagingquot;
else
  abort quot;unknown stage: #{ENV['STAGE']}quot;
end
before :deploy, :run_tests
after quot;deploy:update_codequot;, :link_database_yml
task :run_tests do
  system quot;rakequot; or abort quot;tests failedquot;
end
task :link_database_yml do
  run quot;ln -s #{release_path}/config/database.yml #{shared_path}/database.ymlquot;
end
Cap
•cap -T	
•cap <some task>
•cap invoke COMMAND=quot;df -hquot;
•cap invoke COMMAND=quot;df -hquot; ROLES=sd_db
•cap invoke COMMAND=quot;df -hquot; HOSTS=www.spazidigitali.com
•cap shell
Capify
  capify .




•Creates a Capfile
•Creates a deploy “configuration” file
Cap
•cap deploy:setup       •cap deploy
•cap deploy:check       •cap deploy:rollback
•cap deploy:cold        •cap deploy:migrations
•cap deploy:update      •cap deploy:web:disable
•cap deploy:migrate     •cap deploy:web:enable
•cap deploy:start       •cap deploy:cleanup
deploy:setup
•<deploy_to>
 •current
 •releases
  •200706060120
  •200702020815
 •shared
  •log
  •pids
  •system
deploy:check


depend   :remote, :gem, 'rpdf', '>=1.1.4'
depend   :remote, :directory, quot;/tmp/railsquot;
depend   :remote, :writable, quot;/dir/file.logquot;
depend   :local, :command, quot;gemquot;
depend   :remote, :command, quot;mysqldumpquot;
deploy:cold

•copies the code - cap deploy:update
•migrates the database - cap deploy:migrate
•starts the service - cap deploy:start
Variables
•:ssh_options         •:use_sudo
•:application         •:group_writable
•:repository          •:rake
•:scm                 •:current_path
•:deploy_via          •:release_path
•:deploy_to           •:shared_path
•:revision
Deployment strategies

•Checkout (classic capistrano)
•Remote cache (svn up)
•Export
•Copy (via checkout or export, with compression)
Example*
 *sorta real
That’s all folks


•Luca Mearelli
•http://spazidigitali.com
•lucamea@gmail.com

More Related Content

What's hot

Hacking ansible
Hacking ansibleHacking ansible
Hacking ansiblebcoca
 
How Danga::Socket handles asynchronous processing and how to write asynchrono...
How Danga::Socket handles asynchronous processing and how to write asynchrono...How Danga::Socket handles asynchronous processing and how to write asynchrono...
How Danga::Socket handles asynchronous processing and how to write asynchrono...Gosuke Miyashita
 
SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)Robert Swisher
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and othersYusuke Wada
 
Umleitung: a tiny mochiweb/CouchDB app
Umleitung: a tiny mochiweb/CouchDB appUmleitung: a tiny mochiweb/CouchDB app
Umleitung: a tiny mochiweb/CouchDB appLenz Gschwendtner
 
Ansible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupAnsible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupGreg DeKoenigsberg
 
Ruby off Rails (japanese)
Ruby off Rails (japanese)Ruby off Rails (japanese)
Ruby off Rails (japanese)Stoyan Zhekov
 
Merb Slices
Merb SlicesMerb Slices
Merb Sliceshassox
 
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
"Ops Tools with Perl" 2012/05/12 Hokkaido.pmRyosuke IWANAGA
 
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Anatoly Sharifulin
 
Modern Perl Web Development with Dancer
Modern Perl Web Development with DancerModern Perl Web Development with Dancer
Modern Perl Web Development with DancerDave Cross
 
Asynchronous programming patterns in Perl
Asynchronous programming patterns in PerlAsynchronous programming patterns in Perl
Asynchronous programming patterns in Perldeepfountainconsulting
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsRemy Sharp
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansiblejtyr
 
More tips n tricks
More tips n tricksMore tips n tricks
More tips n tricksbcoca
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by CapistranoTasawr Interactive
 
Devsumi2012 攻めの運用の極意
Devsumi2012 攻めの運用の極意Devsumi2012 攻めの運用の極意
Devsumi2012 攻めの運用の極意Ryosuke IWANAGA
 
Lights, Camera, Docker: Streaming Video at DramaFever
Lights, Camera, Docker: Streaming Video at DramaFeverLights, Camera, Docker: Streaming Video at DramaFever
Lights, Camera, Docker: Streaming Video at DramaFeverbridgetkromhout
 

What's hot (20)

Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
 
How Danga::Socket handles asynchronous processing and how to write asynchrono...
How Danga::Socket handles asynchronous processing and how to write asynchrono...How Danga::Socket handles asynchronous processing and how to write asynchrono...
How Danga::Socket handles asynchronous processing and how to write asynchrono...
 
SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)
 
Inside Bokete: Web Application with Mojolicious and others
Inside Bokete:  Web Application with Mojolicious and othersInside Bokete:  Web Application with Mojolicious and others
Inside Bokete: Web Application with Mojolicious and others
 
Umleitung: a tiny mochiweb/CouchDB app
Umleitung: a tiny mochiweb/CouchDB appUmleitung: a tiny mochiweb/CouchDB app
Umleitung: a tiny mochiweb/CouchDB app
 
Ansible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupAnsible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetup
 
Ruby off Rails (japanese)
Ruby off Rails (japanese)Ruby off Rails (japanese)
Ruby off Rails (japanese)
 
Merb Slices
Merb SlicesMerb Slices
Merb Slices
 
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
"Ops Tools with Perl" 2012/05/12 Hokkaido.pm
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!
 
Modern Perl Web Development with Dancer
Modern Perl Web Development with DancerModern Perl Web Development with Dancer
Modern Perl Web Development with Dancer
 
Asynchronous programming patterns in Perl
Asynchronous programming patterns in PerlAsynchronous programming patterns in Perl
Asynchronous programming patterns in Perl
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansible
 
A Gentle Introduction to Event Loops
A Gentle Introduction to Event LoopsA Gentle Introduction to Event Loops
A Gentle Introduction to Event Loops
 
More tips n tricks
More tips n tricksMore tips n tricks
More tips n tricks
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by Capistrano
 
Devsumi2012 攻めの運用の極意
Devsumi2012 攻めの運用の極意Devsumi2012 攻めの運用の極意
Devsumi2012 攻めの運用の極意
 
Lights, Camera, Docker: Streaming Video at DramaFever
Lights, Camera, Docker: Streaming Video at DramaFeverLights, Camera, Docker: Streaming Video at DramaFever
Lights, Camera, Docker: Streaming Video at DramaFever
 

Viewers also liked (20)

Acabats
AcabatsAcabats
Acabats
 
Dossier textil 1011
Dossier textil 1011Dossier textil 1011
Dossier textil 1011
 
El TèXtil
El TèXtilEl TèXtil
El TèXtil
 
Filatura
FilaturaFilatura
Filatura
 
Les Fibres I Els Teixits
Les Fibres I  Els TeixitsLes Fibres I  Els Teixits
Les Fibres I Els Teixits
 
El tèxtil 2n ESO
El tèxtil 2n ESOEl tèxtil 2n ESO
El tèxtil 2n ESO
 
Produccion del zapato 10 3
Produccion del zapato 10 3Produccion del zapato 10 3
Produccion del zapato 10 3
 
And Now You Have Two Problems
And Now You Have Two ProblemsAnd Now You Have Two Problems
And Now You Have Two Problems
 
Presentacion teler
Presentacion telerPresentacion teler
Presentacion teler
 
El Teler
El TelerEl Teler
El Teler
 
El TèXtil
El TèXtilEl TèXtil
El TèXtil
 
Estudi de processos industrials
Estudi de processos industrialsEstudi de processos industrials
Estudi de processos industrials
 
El tissatge
El tissatgeEl tissatge
El tissatge
 
Les fibres tèxtils
Les fibres tèxtilsLes fibres tèxtils
Les fibres tèxtils
 
Tissatge
TissatgeTissatge
Tissatge
 
Presentación tratamiento plasma
Presentación tratamiento plasmaPresentación tratamiento plasma
Presentación tratamiento plasma
 
Plàstics i materials petris
Plàstics i materials petrisPlàstics i materials petris
Plàstics i materials petris
 
La revolució industrial
La revolució industrialLa revolució industrial
La revolució industrial
 
Ppt cal jepó
Ppt cal jepóPpt cal jepó
Ppt cal jepó
 
Etiquetado de prendas de vestir
Etiquetado de prendas de vestirEtiquetado de prendas de vestir
Etiquetado de prendas de vestir
 

Similar to Capistrano2

Deploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoDeploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoAlmir Mendes
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Librariesjeresig
 
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendWide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendMySQLConference
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2rubyMarc Chung
 
Systems Automation with Puppet
Systems Automation with PuppetSystems Automation with Puppet
Systems Automation with Puppetelliando dias
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceJesse Vincent
 
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)Hari
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppSmartLogic
 
Ruby Isn't Just About Rails
Ruby Isn't Just About RailsRuby Isn't Just About Rails
Ruby Isn't Just About RailsAdam Wiggins
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMySQLConference
 
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)ZFConf Conference
 
Delivering Go.CD with Terraform and Docker
Delivering Go.CD with Terraform and DockerDelivering Go.CD with Terraform and Docker
Delivering Go.CD with Terraform and DockerJorrit Salverda
 

Similar to Capistrano2 (20)

Capistrano
CapistranoCapistrano
Capistrano
 
Capistrano Overview
Capistrano OverviewCapistrano Overview
Capistrano Overview
 
Sinatra
SinatraSinatra
Sinatra
 
Os Furlong
Os FurlongOs Furlong
Os Furlong
 
Deploying Rails Applications with Capistrano
Deploying Rails Applications with CapistranoDeploying Rails Applications with Capistrano
Deploying Rails Applications with Capistrano
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Libraries
 
Capistrano
CapistranoCapistrano
Capistrano
 
Os Wilhelm
Os WilhelmOs Wilhelm
Os Wilhelm
 
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendWide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
Memcached Study
Memcached StudyMemcached Study
Memcached Study
 
Systems Automation with Puppet
Systems Automation with PuppetSystems Automation with Puppet
Systems Automation with Puppet
 
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret SauceBeijing Perl Workshop 2008 Hiveminder Secret Sauce
Beijing Perl Workshop 2008 Hiveminder Secret Sauce
 
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)
Source Code of Building Linux IPv6 DNS Server (Complete Sourcecode)
 
EC2
EC2EC2
EC2
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails App
 
Ruby Isn't Just About Rails
Ruby Isn't Just About RailsRuby Isn't Just About Rails
Ruby Isn't Just About Rails
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With Maatkit
 
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
 
Delivering Go.CD with Terraform and Docker
Delivering Go.CD with Terraform and DockerDelivering Go.CD with Terraform and Docker
Delivering Go.CD with Terraform and Docker
 

More from Luca Mearelli

The anatomy of an infographic
The anatomy of an infographicThe anatomy of an infographic
The anatomy of an infographicLuca Mearelli
 
L'altra meta del web
L'altra meta del webL'altra meta del web
L'altra meta del webLuca Mearelli
 
To Batch Or Not To Batch
To Batch Or Not To BatchTo Batch Or Not To Batch
To Batch Or Not To BatchLuca Mearelli
 
A Little Backbone For Your App
A Little Backbone For Your AppA Little Backbone For Your App
A Little Backbone For Your AppLuca Mearelli
 
Controlling The Cloud With Python
Controlling The Cloud With PythonControlling The Cloud With Python
Controlling The Cloud With PythonLuca Mearelli
 
Introduzione a Ruby On Rails
Introduzione a Ruby On RailsIntroduzione a Ruby On Rails
Introduzione a Ruby On RailsLuca Mearelli
 
Integrating services with OAuth
Integrating services with OAuthIntegrating services with OAuth
Integrating services with OAuthLuca Mearelli
 

More from Luca Mearelli (10)

The anatomy of an infographic
The anatomy of an infographicThe anatomy of an infographic
The anatomy of an infographic
 
L'altra meta del web
L'altra meta del webL'altra meta del web
L'altra meta del web
 
To Batch Or Not To Batch
To Batch Or Not To BatchTo Batch Or Not To Batch
To Batch Or Not To Batch
 
A Little Backbone For Your App
A Little Backbone For Your AppA Little Backbone For Your App
A Little Backbone For Your App
 
WorseSoftware
WorseSoftwareWorseSoftware
WorseSoftware
 
Controlling The Cloud With Python
Controlling The Cloud With PythonControlling The Cloud With Python
Controlling The Cloud With Python
 
Open Web
Open WebOpen Web
Open Web
 
Wikierp
WikierpWikierp
Wikierp
 
Introduzione a Ruby On Rails
Introduzione a Ruby On RailsIntroduzione a Ruby On Rails
Introduzione a Ruby On Rails
 
Integrating services with OAuth
Integrating services with OAuthIntegrating services with OAuth
Integrating services with OAuth
 

Recently uploaded

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Capistrano2

  • 1. Capistrano 2 Beyond Hassle-Free Deployment Luca Mearelli Pisa - Oct. 27, 2007
  • 2.
  • 4. Rails is fun Rails is TOO MUCH fun
  • 7. Rails : Web development = Capistrano : Sys.administration
  • 8. Capistrano basics •SSH to the remote machines •Posix compatible shell •Same password or public key •a bit of ruby knowledge •works from a command line
  • 9. Capistrano basics •Capfile (makefile, rakefile, ...) •It’s ruby task :dump_db, :hosts => quot;database.spazidigitali.comquot; do run quot;mysqldump -u deploy sd_production > /home/luca/dumps/db.sqlquot; end cap dump_db
  • 10. role :sd_db, quot;database.spazidigitali.comquot; task :dump_db do run quot;mysqldump -u deploy sd_production > /home/luca/dumps/db.sqlquot; end task :free_space do run quot;df -hquot; end cap dump_db
  • 11. set :gateway, quot;firewall.spazidigitali.comquot; role :sd_db, quot;database.spazidigitali.comquot; task :dump_db do run quot;mysqldump -u deploy sd_production > /home/luca/dumps/db.sqlquot; end task :free_space do run quot;df -hquot; end cap dump_db
  • 12. set :gateway, quot;firewall.spazidigitali.comquot; role :sd_db, quot;database.spazidigitali.comquot;, quot;replica.spazidigitali.comquot; task :dump_db do run quot;mysqldump -u deploy sd_production > /home/luca/dumps/db.sqlquot; end task :free_space do run quot;df -hquot; end cap dump_db
  • 13. set :gateway, quot;firewall.spazidigitali.comquot; role :sd_db, quot;database.spazidigitali.comquot;, quot;replica.spazidigitali.comquot; role :sd_app, quot;mongrels.spazidigitali.comquot; task :dump_db, :roles=>:sd_db do run quot;mysqldump -u deploy sd_production > /home/luca/dumps/db.sqlquot; end task :free_space, :roles=>[:sd_db, :sd_app ] do run quot;df -hquot; end cap dump_db
  • 14. set :gateway, quot;firewall.spazidigitali.comquot; role :sd_db, quot;database.spazidigitali.comquot;, quot;replica.spazidigitali.comquot; role :sd_app, quot;mongrels.spazidigitali.comquot; namespace :spazidig do desc quot;Dumping our DBsquot; task :dump_db, :roles=>:sd_db do run quot;mysqldump -u deploy sd_production > /home/luca/dumps/db.sqlquot; end desc quot;Checking free spacequot; task :free_space, :roles=>[:sd_db, :sd_app ]do run quot;df -hquot; end end cap spazidig:dump_db
  • 15. set :gateway, quot;firewall.spazidigitali.comquot; role :sd_db, quot;database.spazidigitali.comquot;, quot;replica.spazidigitali.comquot; role :sd_app, quot;mongrels.spazidigitali.comquot; namespace :spazidig do desc quot;What??quot; task :default do run quot;uname -aquot; end desc quot;Dumping our DBsquot; task :dump_db, :roles=>:sd_db do run quot;mysqldump -u deploy sd_production > /home/luca/dumps/db.sqlquot; end desc quot;Checking free spacequot; task :free_space, :roles=>[:sd_db, :sd_app ]do run quot;df -hquot; end end cap spazidig spazidig:dump_db cap dump_db cap spazidig:free_space
  • 16. set :gateway, quot;firewall.spazidigitali.comquot; role :sd_db, quot;database.spazidigitali.comquot;, quot;replica.spazidigitali.comquot; role :sd_app, quot;mongrels.spazidigitali.comquot; set :destination, quot;db.sqlquot; namespace :spazidig do desc quot;Dumping our DBsquot; task :dump_db, :roles=>:sd_db do run quot;mysqldump -u deploy sd_production > /home/luca/dumps/#{destination}.sqlquot; end end cap spazidig:dump_db
  • 17. set :gateway, quot;firewall.spazidigitali.comquot; role :sd_db, quot;database.spazidigitali.comquot;, quot;replica.spazidigitali.comquot; role :sd_app, quot;mongrels.spazidigitali.comquot; set :destination, quot;db.sqlquot; set(:database) do Capistrano::CLI.ui.ask quot;Which database?: quot; end namespace :spazidig do desc quot;Dumping our DBsquot; task :dump_db, :roles=>:sd_db do run quot;mysqldump -u deploy #{database} > /home/luca/dumps/#{destination}.sqlquot; end end cap spazidig:dump_db
  • 18. task :deploy do transaction do try_this then_do_that end end task :try_this do on_rollback { run quot;do_cleanupquot; } #... end task :then_do_that do on_rollback { run quot;do_super_cleanupquot; } #... end
  • 19. on :event, :callback, :only => %w(tasks_to_do) # :load, :exit, :start, :finish, :begin, :after trigger :notify, current_task on :notify, :callback
  • 20. load_paths << quot;config/deployquot; case ENV['STAGE'] when quot;productionquot; then load quot;productionquot; when quot;stagingquot; then load quot;stagingquot; else abort quot;unknown stage: #{ENV['STAGE']}quot; end
  • 21. before :deploy, :run_tests after quot;deploy:update_codequot;, :link_database_yml task :run_tests do system quot;rakequot; or abort quot;tests failedquot; end task :link_database_yml do run quot;ln -s #{release_path}/config/database.yml #{shared_path}/database.ymlquot; end
  • 22. Cap •cap -T •cap <some task> •cap invoke COMMAND=quot;df -hquot; •cap invoke COMMAND=quot;df -hquot; ROLES=sd_db •cap invoke COMMAND=quot;df -hquot; HOSTS=www.spazidigitali.com •cap shell
  • 23. Capify capify . •Creates a Capfile •Creates a deploy “configuration” file
  • 24. Cap •cap deploy:setup •cap deploy •cap deploy:check •cap deploy:rollback •cap deploy:cold •cap deploy:migrations •cap deploy:update •cap deploy:web:disable •cap deploy:migrate •cap deploy:web:enable •cap deploy:start •cap deploy:cleanup
  • 25. deploy:setup •<deploy_to> •current •releases •200706060120 •200702020815 •shared •log •pids •system
  • 26. deploy:check depend :remote, :gem, 'rpdf', '>=1.1.4' depend :remote, :directory, quot;/tmp/railsquot; depend :remote, :writable, quot;/dir/file.logquot; depend :local, :command, quot;gemquot; depend :remote, :command, quot;mysqldumpquot;
  • 27. deploy:cold •copies the code - cap deploy:update •migrates the database - cap deploy:migrate •starts the service - cap deploy:start
  • 28. Variables •:ssh_options •:use_sudo •:application •:group_writable •:repository •:rake •:scm •:current_path •:deploy_via •:release_path •:deploy_to •:shared_path •:revision
  • 29. Deployment strategies •Checkout (classic capistrano) •Remote cache (svn up) •Export •Copy (via checkout or export, with compression)
  • 31. That’s all folks •Luca Mearelli •http://spazidigitali.com •lucamea@gmail.com