budapest.rb 2011/01 - rails deployment

Post on 07-May-2015

2.701 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Rails deployment

Tompa Tamás2011.01.20

témák

• eszközök• környezetek• szerverek, csomagok• deployment• konfiguráció• continous integration (CI)• automatizálás

eszközök

• Bundler – gem függőségek• Capistrano – deployment• SVN - verziókövető• Rake – build tasks• CruiseControl.rb - integration• Passenger – mod_rails (futtató

környezet)

Bundler

gembundler.comGEM

• Gemfile• bundle install• bundle install --deployment• bundle exec

Bundler

• Pontos verzió megadás– gem 'mysql2', '=0.2.6'

• Esetleg minor verzió váltás– gem 'will_paginate', '~>3.0.pre2'

• Fejlesztői gem-ek külön– group :development do

Capistrano

github.com/capistrano/capistranoGEM

• capistrano-ext

• capistrano_colors

• capistrano_branching

• Capfile

• cap staging deploy

CruiseControl

cruisecontrolrb.thoughtworks.comRails app

• cruise_config.rb• build_my_app.sh• cruise.rake

• cruise start

CruiseControl

build_my_app.sh bundle install --deployment rake cruise:start

cruise_config.rb project.build_command = './build_my_app.sh'

Passenger

modrails.comRails/Rack server (apache, nginx)

• config.ru (Rack)• RailsEnv, RackEnv

• touch tmp/restart.txt

DiNa

releases.txt- Project changelog- Deployment = Release

cronbuilder- multi server cron jobs- cat ~/.cronbuilder/* | crontab -

környezetek

● Development● Test (= Cucumber)● Cruise● Staging● (Customertest)● Production

környezetek

dev, test

dev, test

dev, test

staging

customer

production

cruise

szerverek

● SSH / SCP● Mindenhol azonos verziók● Mindenhol azonos csomagok● Egységes update policy● Staging: build server is lehet, dev

csomagok, esetleg debug● Production: csak ami a futtatáshoz

kell

deployment

● Capistrano● Deploy strategy (Copy)● Recipe

● Copy Strategy with Bundler● Update copy cache● Excludes● Running bundler with deploy mode● Compressing● Uploading

https://gist.github.com/788136

deploymentdeploy.rb

● set :stages, %w(staging production)● require 'capistrano/ext/multistage'

● set :application, "APP_NAME"

● set :deploy_via, :copy

● set :copy_cache, true● set :copy_exclude, [".svn", "*/.svn", "log"]● set :copy_via, :scp

● set :rake, "bundle exec rake"

deployment

Capfile● after 'deploy:setup', 'deploy:create_shared_dirs'

● after 'deploy:update_code', 'deploy:finalize_code'

● after 'deploy:finalize_code', 'deploy:setup_cron'

● after 'deploy:finalize_code', 'deploy:web:disable'

● after 'deploy:start', 'deploy:web:enable'

Capistrano tests

● Minden jól le is futott?● Jogosultságok● Process-ek● Integrity check● deploy:check hook-ok● Rollback esetek is!

CI

● 2 CI server● Instant build

● Automatizált tesztek (rspec, cucumber)● Azonnal előjönnek a hibák● Gyors javítási lehetőség● Komplex, hosszan futó tesztek kihagyása

● Daily build● Naponta csak 1x fut le● A hosszan futó tesztek csak itt● Metrikák – metrics_fu gem● SVN analízis - svnstat

CI

● Build game● Nabaztag notifier

● Gyulahttp://vimeo.com/17637539

Mit automatizáljunk?

● Tesztek● Continous Integration

● Sikeres daily build esetén – auto staging deploy

● Deployment● De mindig kell manuális tesztelés is!

Mit ne automatizáljunk?

● Customertest/Production deploy manuális!

● Interaktív deployment● capistrano_branching tool

● trunk → branches/stable● branches/stable → branches/production

folyt köv

• Köszönöm!

• Blog: http://digitalnatives.blog.hu/

top related