Slide 1

Slide 1 text

ͦ ͏ ͩ R a c k ࡞ Ζ ͏ ɻ

Slide 2

Slide 2 text

5PEBZ`T(PBM w 3BDLͱ͸Կ͔ཧղ͢Δ w 3BDLΞϓϦϛυϧ΢ΣΞΛ࡞ΕΔΑ͏ʹͳΔ

Slide 3

Slide 3 text

"HFOEB 3BDLͱ͸ 3BDLΞϓϦΛ࡞ͬͯΈΑ͏ 3BDLϛυϧ΢ΣΞΛ࡞ͬͯΈΑ͏ (FNʹͯ͠ΈΑ͏ʢ͓·͚ʣ 6OJDPSOͰಈ͔ͯ͠ΈΑ͏ʢ͓·͚ʣ

Slide 4

Slide 4 text

3BDLͱ͸

Slide 5

Slide 5 text

3BDLͱ͸ 3VCZΛαϙʔτ͢Δ8FC "1 αʔόͱ 3VCZϑϨʔϜϫʔΫͱΛͭͳ͙ن໿ 1ZUIPOͷ84(*ΛݩʹఏҊ͞Εͨ

Slide 6

Slide 6 text

3BDLͷ໾ׂ Passenger Unicorn Thin Mongrel Rails Sinatra Ramaze Merb Application Server Framework ΠϯλʔϑΣʔεͷ౷ҰʹΑΓɺ ϑϨʔϜϫʔΫʗAPαʔόؒͷ૊Έ߹ΘͤΛࣗ༝ʹ͢Δ

Slide 7

Slide 7 text

3BDLΞϓϦΛ࡞ͬͯΈΑ͏

Slide 8

Slide 8 text

! wDBMMͱ͍͏ϝιουΛ͍࣋ͬͯΔ͜ͱ wDBMMϝιουͷҾ਺ͱͯ͠8FCαʔό͔ΒͷϦΫΤετ Λड͚Δ͜ͱ wDBMMϝιου͸ҎԼͷཁૉΛؚΉϨεϙϯεΛฦ͢͜ͱ εςʔλείʔυ Ϩεϙϯεϔομʢ)BTIʣ ϨεϙϯεϘσΟʢ"SSBZʣ 3BDLΞϓϦέʔγϣϯ

Slide 9

Slide 9 text

3BDLΞϓϦΛ࡞ͬͯΈΑ͏ class RackApp def call(env) [200, {'Content-Type' => 'text/html'}, ["Hello, Rack world!"]] end end run RackApp.new DPOpHSV ! $ rackup config.ru

Slide 10

Slide 10 text

3BDLϛυϧ΢ΣΞΛ ࡞ͬͯΈΑ͏

Slide 11

Slide 11 text

3BDLϛυϧ΢ΣΞ 3BDLʹରԠͨ͠ΞϓϦέʔγϣϯʹ ػೳΛ௥Ճ͢ΔͨΊͷϛυϧ΢ΣΞ ! w3BDLΞϓϦέʔγϣϯͷ࢓༷Λຬ͍ͨͯ͠Δ͜ͱ wOFXͷୈҰҾ਺ʹଞͷ3BDLΞϓϦέʔγϣϯΛऔΔ͜ͱ

Slide 12

Slide 12 text

3BDLϛυϧ΢ΣΞΛ࡞ͬͯΈΑ͏ class UpcaseAll def initialize(app) @app = app end def call(env) code, headers, body = @app.call(env) body.each {|part| part.upcase! } [code, headers, body] end end class RackApp #... end use UpcaseAll run RackApp.new DPOpHSV

Slide 13

Slide 13 text

3BDLϛυϧ΢ΣΞͷೖΕࢠߏ଄

Slide 14

Slide 14 text

Α͘࢖͏3BDLϥΠϒϥϦ w3BDL3FRVFTU ϦΫΤετΛѻ͍΍ͯ͘͘͢͠ΕΔϥούʔ w3BDL3FTQPOTF ϨεϙϯεΛѻ͍΍ͯ͘͘͢͠ΕΔϥούʔ w3BDL63-.BQ ύεʹԠͯ͡ϦΫΤετΛৼΓ෼͚ͯ͘ΕΔΞϓϦέʔγϣϯ ! ‣ࢀߟɿIUUQSPVUFOFUX3BDL3FGFSFODF+BIUNM

Slide 15

Slide 15 text

ʲԋशʳ ! ͜Ε·ͰֶΜͩ͜ͱΛ౿·͑ͯɺ ΦϦδφϧͷ3BDLϛυϧ΢ΣΞΛ࡞ͬͯΈΑ͏

Slide 16

Slide 16 text

(FNʹͯ͠ΈΑ͏

Slide 17

Slide 17 text

(FNͷ࡞Γํ require "my_first_gem/version" module MyFirstGem class UpcaseAll #... end end $ bundle gem my_first_gem (FNͷ਽ܗΛ࡞Δ ֓ཁΛHFNTQFDʹॻ͘ ϥΠϒϥϦΛॻ͘ (FNΛϏϧυ͢Δ $ rake build

Slide 18

Slide 18 text

ʲԋशʳ ! ࣗ࡞ͨ͠(FNΛHFNJOBCPYʹΞοϓͯ͠ɺ ଞਓ͕࡞ͬͨ(FN΋Πϯετʔϧͯ͠ΈΑ͏

Slide 19

Slide 19 text

6OJDPSOͰಈ͔ͯ͠ΈΑ͏

Slide 20

Slide 20 text

6OJDPSOͷ࢖͍ํ worker_processes 2 listen 9292 stderr_path File.expand_path('unicorn.log', File.dirname(__FILE__)) stdout_path File.expand_path('unicorn.log', File.dirname(__FILE__)) pid File.expand_path('unicorn.pid', File.dirname(__FILE__)) $ echo “gem ‘unicorn’” >> Gemfile $ bundle install 6OJDPSOΛΠϯετʔϧ ઃఆϑΝΠϧʢVOJDPSODPOGʣΛ༻ҙ͢Δ 6OJDPSOΛىಈ͢Δ 6OJDPSOΛఀࢭ͢Δ $ kill -QUIT `cat unicorn.pid` $ unicorn -c unicorn.conf -D