Save 37% off PRO during our Black Friday Sale! »

Capistrano

932023bba90ce8911667a5a093e2d1d9?s=47 qutic
October 01, 2013

 Capistrano

Deployment mit Capistrano

932023bba90ce8911667a5a093e2d1d9?s=128

qutic

October 01, 2013
Tweet

Transcript

  1. © 2013 stefan.husch@qutic.com Capistrano

  2. Stefan Husch

  3. ‣ Inhaber ‚qutic development‘ : Beratung, Entwicklung und Hosting ‣

    Software-Entwicklung seit 1983 ‣ Start mit Basic und Assembler auf dem C64 ‣ Seit 1993 MacOS, ab 2000 MacOS X: C, Objective-C ‣ Web-Entwicklung mit Ruby (On Rails) seit Ende 2005
  4. Introducing SwitchTower Posted by Jamis Buck on August 05, 2005

    @ 05:43 PM
  5. SwitchTower: Renamed Posted by Jamis Buck on March 05, 2006

    @ 05:49 PM
  6. Capistrano

  7. Application Deployment Tool

  8. geschrieben in Ruby

  9. mit einer einfachen DSL für die Konfiguration

  10. zur Ausführung auf der Kommandozeile

  11. cap deploy

  12. ... und Capistrano macht das Heavy Lifting :-)

  13. ‣ Applikation aus scm auschecken und auf Server kopieren ‣

    Wartungsseite schalten ‣ Hintergrund-Prozesse beenden ‣ fehlende Bibliotheken nachinstallieren ‣ Datenbank migrieren ‣ Ordner in Projekt hineinlinken (files, logs, etc) ‣ Hintergrund-Prozesse wieder starten ‣ Memcache-Instanz zurücksetzen (flush_all) ‣ Sphinx-Datenbank indizieren und Prozess neu starten ‣ Applikation neu starten ‣ Wartungsseite entfernen ‣ Alte Deployments entfernen
  14. Einfache Installation

  15. nur auf dem Deployment-Rechner!

  16. gem install capistrano cd /mein/projekt capify . nano config/deploy.rb

  17. set :location, "radiantmagic.com" set :user, "radiantic" set :port, 10900 set

    :use_sudo, false set :application, "radiantic" set :scm, :git set :repository, "git@mein-git-srv:radiantic.git" set :branch, "master" set :deploy_via, :rsync_with_remote_cache set :deploy_to, "/export/home/#{user}/www/#{application}"
  18. Ausführung über SSH

  19. mit Ruby >= 1.9 auch parallel

  20. Und wenn etwas schief geht?

  21. cap deploy:rollback

  22. Spezielle Ordner-Struktur

  23. radiantic current -> releases/20130609164855 releases 20130608155124 20130609164855 shared config database.yml

    log production.log sphinx files
  24. desc "Migrate database" task :migrate, :roles => :db do run

    "cd '#{current_path}' && /rake db:migrate" end desc "Delete cache" task :cache_clear, :roles => :worker do delete "#{shared_path}/tmp/cache", :recursive => true end desc "Restart application" task :restart, :roles => :app do run "touch '#{current_path}/tmp/restart.txt'" end desc "Restart Webserver" task :restart_webserver, :roles => : app do sudo "/etc/init.d/apache2 restart" end
  25. Namespaces

  26. namespace :dj do desc "Start delayed_job backgound worker" task :start,

    :roles => :worker do run "'#{current_path}/script/delayed_job' start -n 4" end desc "Stop delayed_job backgound worker" task :stop, :roles => :worker do run "'#{current_path}/script/delayed_job' stop" end desc "Restart delayed_job backgound worker" task :restart, :roles => :worker do stop start end end
  27. Callbacks

  28. before "deploy:update_code", "deploy:dj:stop" before "deploy:restart", "deploy:bundle" after "deploy:bundle", "deploy:migrate" after

    "deploy:migrate", "deploy:cache_clear"
  29. Rollen

  30. role :app, "web1.example.com", "web2.example.com" role :web, "web1.example.com", "web2.example.com" role :db,

    "web1.example.com", :primary => true role :worker, "web2.example.com"
  31. Multistage

  32. Erweiterbar

  33. None
  34. GUI

  35. Webistrano

  36. a Web UI for managing Capistrano deployment

  37. Harrow.io

  38. SaaS für Deployment?

  39. there is one more thing...

  40. cap shell

  41. Orchestration

  42. task "puppet:stop" task "puppet:start" task "puppet:restart" task "zone:stop" task "zone:start"

    task "zone:restart" task "db:switch_master" task "db:switch_proxy"
  43. ?

  44. Quellen ‣ https://github.com/capistrano/capistrano ‣ http://de.wikipedia.org/wiki/Capistrano_(Software) ‣ http://www.capistranorb.com ‣ http://weblog.jamisbuck.org/2005/8/5/introducing-switchtower ‣

    http://weblog.jamisbuck.org/2006/3/6/switchtower-renamed ‣ https://github.com/peritor/webistrano ‣ https://www.harrow.io ‣ http://stackoverflow.com/questions/tagged/capistrano