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
Golangで学ぶHot deployの仕組み
Search
tsurubee
June 28, 2018
Programming
2
1.2k
Golangで学ぶHot deployの仕組み
Server::Starterの仕組みを学び、Golangでミニマムで 実装してみた
tsurubee
June 28, 2018
Tweet
Share
More Decks by tsurubee
See All by tsurubee
DeepCrysTet: A Deep Learning Approach Using Tetrahedral Mesh for Predicting Properties of Crystalline Materials
tsurubee
0
670
3次元メッシュで表現した結晶構造を用いた材料物性の予測に向けた深層学習モデルの設計 / Design of Deep Learning Model for Predicting Material Properties Using Crystal Structure Represented by Three-Dimensional Mesh
tsurubee
1
1.9k
分散システムの性能異常に対する機械学習の解釈性に基づく原因診断手法 / A Method for Diagnosing the Causes of Performance Issues in Distributed Systems Based on the Interpretability of Machine Learning
tsurubee
0
1.3k
機械学習の解釈性に関する研究動向とシステム運用への応用 / A Survey on Interpretable Machine Learning and Its Application for System Operation
tsurubee
0
290
機械学習モデルの局所的な解釈に着目したシステムにおける異常の原因診断手法の構想
tsurubee
0
7.7k
アニーリングマシンを活用したエッジAIにおける 生成モデルの学習効率化のためのアーキテクチャ
tsurubee
0
1.4k
さくらインターネット研究所で研究に再挑戦した私の半年間の取り組み
tsurubee
1
2.8k
さくらインターネット研究所と鶴田の取り組みのご紹介
tsurubee
0
100
sshr: ユーザに変更を要求せずにシステム変化に追従可能なSSHプロキシサーバ
tsurubee
3
2.9k
Other Decks in Programming
See All in Programming
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
860
Remix on Hono on Cloudflare Workers
yusukebe
1
280
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
subpath importsで始めるモック生活
10tera
0
300
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
EventSourcingの理想と現実
wenas
6
2.3k
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
870
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
CSC509 Lecture 12
javiergs
PRO
0
160
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
330
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
520
39k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Writing Fast Ruby
sferik
627
61k
What's in a price? How to price your products and services
michaelherold
243
12k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
860
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Teambox: Starting and Learning
jrom
133
8.8k
4 Signs Your Business is Dying
shpigford
180
21k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Transcript
!UTVSVCFF(.01FQBCP *OD भΠϯϑϥަྲྀษڧձ ,JYT 7PM (PMBOHͰֶͿ )PUEFQMPZͷΈ
(.0ϖύϘɹΠϯϑϥΤϯδχΞ !UTVSVCFF
݄(.0ϖύϘೖࣾ ΠϯϑϥΤϯδχΞྺϲ݄
࣍ w)PUEFQMPZͱʁͳͥඞཁ͔ʁ w)PUEFQMPZͷΈ w(PMBOHͰ࣮ͯ͠Έͨ
͍͑ͨ͜ͱ wμϯλΠϜθϩΛࢧ͑Δ)PUEFQMPZͷΈͷҰྫ w(PMBOHΛ௨ͯ͡ϨΠϠʔͷٕज़ΛֶͿ͜ͱͰɺ ΤϯδχΞͱͯ͠ͷ෯͕͕ΔͷͰʁ wٕज़ॻಡΜͰ;Ή;Ή͢ΔΑΓ࣮ͯ͠Έͨํ͕ཧղ ͍͢͠
)PUEFQMPZͱʁ ͳͥඞཁ͔ʁ
)PUEFQMPZͱʁ wΞϓϦέʔγϣϯʹϩδοΫઃఆͷมߋΛՃ͑ͨࡍ ʹɺϦΫΤετͷॲཧΛଓ͚ଓ͚ͳ͕Βɺมߋͷ༰Λ ө͢ΔͨΊͷखஈ
)PUEFQMPZͱʁ wΞϓϦέʔγϣϯʹϩδοΫઃఆͷมߋΛՃ͑ͨࡍ ʹɺϦΫΤετͷॲཧΛଓ͚ଓ͚ͳ͕Βɺมߋͷ༰Λ ө͢ΔͨΊͷखஈ ҰൠతͳσϓϩΠʢ/05)PUEFQMPZʣ 4PVSDFDPEF DIBOHF (PMBOHͷ߹ɺ όΠφϦͷ্ॻ͖
)PUEFQMPZͱʁ wΞϓϦέʔγϣϯʹϩδοΫઃఆͷมߋΛՃ͑ͨࡍ ʹɺϦΫΤετͷॲཧΛଓ͚ଓ͚ͳ͕Βɺมߋͷ༰Λ ө͢ΔͨΊͷखஈ ҰൠతͳσϓϩΠʢ/05)PUEFQMPZʣ 4PVSDFDPEF DIBOHF "QQMJDBUJPO 4UPQ (PMBOHͷ߹ɺ
όΠφϦͷ্ॻ͖
)PUEFQMPZͱʁ wΞϓϦέʔγϣϯʹϩδοΫઃఆͷมߋΛՃ͑ͨࡍ ʹɺϦΫΤετͷॲཧΛଓ͚ଓ͚ͳ͕Βɺมߋͷ༰Λ ө͢ΔͨΊͷखஈ ҰൠతͳσϓϩΠʢ/05)PUEFQMPZʣ 4PVSDFDPEF DIBOHF "QQMJDBUJPO 4UPQ "QQMJDBUJPO
4UBSU (PMBOHͷ߹ɺ όΠφϦͷ্ॻ͖ ࠶ىಈ
)PUEFQMPZͱʁ wΞϓϦέʔγϣϯʹϩδοΫઃఆͷมߋΛՃ͑ͨࡍ ʹɺϦΫΤετͷॲཧΛଓ͚ଓ͚ͳ͕Βɺมߋͷ༰Λ ө͢ΔͨΊͷखஈ ҰൠతͳσϓϩΠʢ/05)PUEFQMPZʣ 4PVSDFDPEF DIBOHF "QQMJDBUJPO 4UPQ "QQMJDBUJPO
4UBSU (PMBOHͷ߹ɺ όΠφϦͷ্ॻ͖ ϦΫΤετΛॲཧ Ͱ͖ͳ͍͕࣌ؒൃੜ ࠶ىಈ
)PUEFQMPZ͕ͳͥඞཁ͔ʁ wΘ͔ͣͳؒͰՔಇ͍ͯ͠ΔαʔϏεΛࢭΊͨ͘ͳ͍ w)PUEFQMPZΛಋೖ͢Δ͜ͱͰɺγεςϜӡ༻ʹ͓͚Δ อकੑ্͕͠ɺਝͳ։ൃαΠΫϧ͕࣮ݱͰ͖Δ
)PUEFQMPZͷΈ
4FSWFS4UBSUFS w؆୯ʹ)PUEFQMPZͰ͖ΔΑ͏ʹ͢ΔͨΊͷDQBONPEVMF w1FSMͰ࣮͞Ε͍ͯΔ͕ɺγάφϧͱڥมΛͬͨ ൚༻ੑͷߴ͍ΈͷͨΊɺ͞·͟·ͳݴޠͰར༻Մೳ
4FSWFS4UBSUFS w؆୯ʹ)PUEFQMPZͰ͖ΔΑ͏ʹ͢ΔͨΊͷDQBONPEVMF w1FSMͰ࣮͞Ε͍ͯΔ͕ɺγάφϧͱڥมΛͬͨ ൚༻ੑͷߴ͍ΈͷͨΊɺ͞·͟·ͳݴޠͰར༻Մೳ ಈ࡞Λݴ༿Ͱઆ໌͢Δͱɾɾ ʮ৽͍͠ϓϩηεΛىಈͯ͠৽͍͠ϦΫΤετΛͦͪΒʹ ྲྀͭͭ͠ɺݹ͍ϓϩηεͷϦΫΤετ͕ྃͨ͠Βਖ਼͘͠ ऴྃͤ͞Δʯ
4FSWFS4UBSUFS w؆୯ʹ)PUEFQMPZͰ͖ΔΑ͏ʹ͢ΔͨΊͷDQBONPEVMF w1FSMͰ࣮͞Ε͍ͯΔ͕ɺγάφϧͱڥมΛͬͨ ൚༻ੑͷߴ͍ΈͷͨΊɺ͞·͟·ͳݴޠͰར༻Մೳ ಈ࡞Λݴ༿Ͱઆ໌͢Δͱɾɾ ʮ৽͍͠ϓϩηεΛىಈͯ͠৽͍͠ϦΫΤετΛͦͪΒʹ ྲྀͭͭ͠ɺݹ͍ϓϩηεͷϦΫΤετ͕ྃͨ͠Βਖ਼͘͠ ऴྃͤ͞Δʯ (SBDFGVM3FTUBSUʢ༏խͳ࠶ىಈʣ
)PUEFQMPZͷΈʢ؆қ൛ʣ TUBSU@TFSWFS 1BSFOU start_server —-port 8888 —- ./server TFSWFS $IJME
TPDLFU GPSLFYFD TPDLFUΛڞ༗ BDDFQU TUBSU@TFSWFSɿ(SBDFGVMSFTUBSUͷͨΊͷϓϩάϥϜ TFSWFSɿ࣮ߦ͍ͨ͠ϓϩάϥϜ
)PUEFQMPZͷΈʢ؆қ൛ʣ TUBSU@TFSWFS 1BSFOU start_server —-port 8888 —- ./server TFSWFS $IJME
TPDLFU GPSLFYFD TPDLFUΛڞ༗ BDDFQU TUBSU@TFSWFSɿ(SBDFGVMSFTUBSUͷͨΊͷϓϩάϥϜ TFSWFSɿ࣮ߦ͍ͨ͠ϓϩάϥϜ ᶃϓϩάϥϜʹมߋʂ
)PUEFQMPZͷΈʢ؆қ൛ʣ kill -HUP <master pid> TPDLFU BDDFQU TUBSU@TFSWFS 1BSFOU TFSWFS
$IJME TUBSU@TFSWFSɿ(SBDFGVMSFTUBSUͷͨΊͷϓϩάϥϜ TFSWFSɿ࣮ߦ͍ͨ͠ϓϩάϥϜ ᶄ4*()61 ᶃϓϩάϥϜʹมߋʂ
)PUEFQMPZͷΈʢ؆қ൛ʣ kill -HUP <master pid> TPDLFU GPSLFYFD TFSWFS $IJME ᶄ4*()61
BDDFQU BDDFQU TUBSU@TFSWFS 1BSFOU TFSWFS $IJME ᶅ৽ϓϩάϥϜͰىಈ ᶃϓϩάϥϜʹมߋʂ
)PUEFQMPZͷΈʢ؆қ൛ʣ kill -HUP <master pid> TPDLFU ऴྃ͢Δલʹʜ ᶃ৽نϦΫΤεड ɹͷఀࢭ ᶄݱࡏॲཧதͷ
ϦΫΤετͷྃ GPSLFYFD (SBDFGVM4IVUEPXO BDDFQU BDDFQU TUBSU@TFSWFS 1BSFOU TFSWFS $IJME ᶅ৽ϓϩάϥϜͰىಈ ᶄ4*()61 ᶆ4*(5&3. TFSWFS $IJME ᶃϓϩάϥϜʹมߋʂ
)PUEFQMPZͷΈʢ؆қ൛ʣ TUBSU@TFSWFS 1BSFOU kill -HUP <master pid> TPDLFU GPSLFYFD TFSWFS
$IJME BDDFQU ᶆ4*(5&3. ᶅ৽ϓϩάϥϜͰىಈ ᶄ4*()61 TFSWFS $IJME ᶃϓϩάϥϜʹมߋʂ ऴྃ͢Δલʹʜ ᶃ৽نϦΫΤεड ɹͷఀࢭ ᶄݱࡏॲཧதͷ ϦΫΤετͷྃ (SBDFGVM4IVUEPXO
࣮ͯ͠Έͨ
ϛχϚϜͰ࣮ͯ͠Έͨ IUUQTHJUIVCDPNUTVSVCFFHSBDFGVMSFTUBSUHP
࣮ϙΠϯτ̍ʙγάφϧϋϯυϥ func waitSignal(l net.Listener) { c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGTERM) go func() { sig := <-c switch sig { case syscall.SIGTERM: signal.Stop(c) l.Close() } }() } γάφϧͱϓϩηεؒ௨৴ͷҰछ ϓϩηεʹγάφϧΛૹ৴͢Δͱɺͦͷϓϩηεͷਖ਼ৗॲཧʹׂΓࠐΜͰɺ γάφϧݻ༗ͷॲཧΛ࣮ߦͰ͖Δ ͓खܰʹγάφϧͷϋϯυϦϯά͕ Ͱ͖Δ
࣮ϙΠϯτ̍ʙγάφϧϋϯυϥ func waitSignal(l net.Listener) { c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGTERM) go func() { sig := <-c switch sig { case syscall.SIGTERM: signal.Stop(c) l.Close() } }() } γάφϧͱϓϩηεؒ௨৴ͷҰछ ϓϩηεʹγάφϧΛૹ৴͢Δͱɺͦͷϓϩηεͷਖ਼ৗॲཧʹׂΓࠐΜͰɺ γάφϧݻ༗ͷॲཧΛ࣮ߦͰ͖Δ HPSPVUJOFͰγάφϧΛͪड͚Δ ͓खܰʹγάφϧͷϋϯυϦϯά͕ Ͱ͖Δ
࣮ϙΠϯτ̎ʙϑΝΠϧσΟεΫϦϓλ func forkExec(l *net.TCPListener) (*os.Process, error) { progName, _ :=
exec.LookPath(os.Args[0]) pwd, _ := os.Getwd() f, _ := l.File() defer f.Close() files := []*os.File{os.Stdin, os.Stdout, os.Stderr, f} fdEnv := fmt.Sprintf("%s=%d", "FD_KEY", len(files)-1) return os.StartProcess(progName, os.Args, &os.ProcAttr{ Dir: pwd, Env: append(os.Environ(), fdEnv), Files: files, }) } ϑΝΠϧσΟεΫϓϦΫλɺϑΝΠϧιέοτͳͲΛநԽͨ͠Έ ϓϩηεΛGPSLͨ͠ࡍɺϓϩηεͷϑΝΠϧσΟεΫϦϓλΛҾ͖ܧ͙
·ͱΊ w4FSWFS4UBSUFSͷΈΛֶͼɺ(PMBOHͰϛχϚϜͰ ࣮ͯ͠Έͨ wγάφϧϑΝΠϧσΟεΫϦϓλͱ͍ͬͨ֓೦ٕज़ॻΛಡ ΜͰ;Ή;Ή͢ΔΑΓɺ࣮ͯ͠Έͨ΄͏͕ཧղ͔ͬͨ͢͠ w(PMBOHଟ͘ͷ04ͷػೳΛ؆ܿͳίʔυͰѻ͑ΔͨΊɺ ࣗͷؔ৺ྖҬΛΑΓ͍ϨΠϠʔʹ͍͛ͯͨ͘Ίʹ దͨ͠ݴޠͩ
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂʂ