Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
そうだ Rack 作ろう。
Search
rince
July 30, 2014
Programming
2
90
そうだ Rack 作ろう。
社内勉強会でRackについて説明した際の資料です。
rince
July 30, 2014
Tweet
Share
More Decks by rince
See All by rince
あらゆる商品を扱う商品データベースを再設計した話 / product db re-architecture
rince
11
5.9k
Elasticsearch入門 〜前編〜
rince
0
250
Railsで海外9ヵ国にサービス展開している話 / Rails i18n
rince
3
1.7k
ActiveSupport::Concern で学ぶRuby
rince
1
300
Railsを6年間やってきたぼくが最近Railsでハマったこと
rince
3
550
プロジェクトをまたいだIssue管理
rince
0
2.2k
Lean Startup
rince
0
170
Yahoo!主催のOpenHackDayJapanに参加してJAXA賞をいただきました
rince
1
130
Other Decks in Programming
See All in Programming
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
250
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
970
ヤプリ新卒SREの オンボーディング
masaki12
0
130
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
540
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
610
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
CSC509 Lecture 11
javiergs
PRO
0
180
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
Amazon Qを使ってIaCを触ろう!
maruto
0
410
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
300
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
510
110k
What's in a price? How to price your products and services
michaelherold
243
12k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Building an army of robots
kneath
302
43k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
420
Happy Clients
brianwarren
98
6.7k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Building Adaptive Systems
keathley
38
2.3k
Transcript
ͦ ͏ ͩ R a c k ࡞ Ζ ͏
ɻ
5PEBZ`T(PBM w 3BDLͱԿ͔ཧղ͢Δ w 3BDLΞϓϦϛυϧΣΞΛ࡞ΕΔΑ͏ʹͳΔ
"HFOEB 3BDLͱ 3BDLΞϓϦΛ࡞ͬͯΈΑ͏ 3BDLϛυϧΣΞΛ࡞ͬͯΈΑ͏ (FNʹͯ͠ΈΑ͏ʢ͓·͚ʣ
6OJDPSOͰಈ͔ͯ͠ΈΑ͏ʢ͓·͚ʣ
3BDLͱ
3BDLͱ 3VCZΛαϙʔτ͢Δ8FC "1 αʔόͱ 3VCZϑϨʔϜϫʔΫͱΛͭͳ͙ن 1ZUIPOͷ84(*ΛݩʹఏҊ͞Εͨ
3BDLͷׂ Passenger Unicorn Thin Mongrel Rails Sinatra Ramaze Merb Application
Server Framework ΠϯλʔϑΣʔεͷ౷ҰʹΑΓɺ ϑϨʔϜϫʔΫʗAPαʔόؒͷΈ߹ΘͤΛࣗ༝ʹ͢Δ
3BDLΞϓϦΛ࡞ͬͯΈΑ͏
! wDBMMͱ͍͏ϝιουΛ͍࣋ͬͯΔ͜ͱ wDBMMϝιουͷҾͱͯ͠8FCαʔό͔ΒͷϦΫΤετ Λड͚Δ͜ͱ wDBMMϝιουҎԼͷཁૉΛؚΉϨεϙϯεΛฦ͢͜ͱ εςʔλείʔυ Ϩεϙϯεϔομʢ)BTIʣ
ϨεϙϯεϘσΟʢ"SSBZʣ 3BDLΞϓϦέʔγϣϯ
3BDLΞϓϦΛ࡞ͬͯΈΑ͏ class RackApp def call(env) [200, {'Content-Type' => 'text/html'}, ["Hello,
Rack world!"]] end end run RackApp.new DPOpHSV ! $ rackup config.ru
3BDLϛυϧΣΞΛ ࡞ͬͯΈΑ͏
3BDLϛυϧΣΞ 3BDLʹରԠͨ͠ΞϓϦέʔγϣϯʹ ػೳΛՃ͢ΔͨΊͷϛυϧΣΞ ! w3BDLΞϓϦέʔγϣϯͷ༷Λຬ͍ͨͯ͠Δ͜ͱ wOFXͷୈҰҾʹଞͷ3BDLΞϓϦέʔγϣϯΛऔΔ͜ͱ
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
3BDLϛυϧΣΞͷೖΕࢠߏ
Α͘͏3BDLϥΠϒϥϦ w3BDL3FRVFTU ϦΫΤετΛѻ͍ͯ͘͘͢͠ΕΔϥούʔ w3BDL3FTQPOTF ϨεϙϯεΛѻ͍ͯ͘͘͢͠ΕΔϥούʔ w3BDL63-.BQ ύεʹԠͯ͡ϦΫΤετΛৼΓ͚ͯ͘ΕΔΞϓϦέʔγϣϯ ! ‣ࢀߟɿIUUQSPVUFOFUX3BDL3FGFSFODF+BIUNM
ʲԋशʳ ! ͜Ε·ͰֶΜͩ͜ͱΛ౿·͑ͯɺ ΦϦδφϧͷ3BDLϛυϧΣΞΛ࡞ͬͯΈΑ͏
(FNʹͯ͠ΈΑ͏
(FNͷ࡞Γํ require "my_first_gem/version" module MyFirstGem class UpcaseAll #... end end
$ bundle gem my_first_gem (FNͷܗΛ࡞Δ ֓ཁΛHFNTQFDʹॻ͘ ϥΠϒϥϦΛॻ͘ (FNΛϏϧυ͢Δ $ rake build
ʲԋशʳ ! ࣗ࡞ͨ͠(FNΛHFNJOBCPYʹΞοϓͯ͠ɺ ଞਓ͕࡞ͬͨ(FNΠϯετʔϧͯ͠ΈΑ͏
6OJDPSOͰಈ͔ͯ͠ΈΑ͏
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