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
Laravel5でJob_Queue実装した話_v1.0.1
Search
NakanishiTetsuhiro
March 06, 2019
Technology
1
48
Laravel5でJob_Queue実装した話_v1.0.1
修正版でございます
NakanishiTetsuhiro
March 06, 2019
Tweet
Share
More Decks by NakanishiTetsuhiro
See All by NakanishiTetsuhiro
コメントの書き方から見る 良いコードについての考察
nakanishitetsuhiro
0
590
SelfIntroduction
nakanishitetsuhiro
0
45
Laravelで設計する際の ベストプラクティスを探る
nakanishitetsuhiro
0
2k
MackerelでECS on Fargate 監視してみた
nakanishitetsuhiro
0
820
WebエンジニアによるWebエンジニアのための今だからこそおすすめしたいLinux環境
nakanishitetsuhiro
1
85
本番環境をECSで構築した話
nakanishitetsuhiro
0
830
Laravel5でjobque実装した話
nakanishitetsuhiro
0
92
社会人による社会人のための友達づくりのすゝめ
nakanishitetsuhiro
0
43
RancherにDocker初心者がチャレンジしてみた!.pdf
nakanishitetsuhiro
0
410
Other Decks in Technology
See All in Technology
SRE×AIOpsを始めよう!GuardDutyによるお手軽脅威検出
amixedcolor
0
170
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
140
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.9k
Lexical Analysis
shigashiyama
1
150
マルチプロダクトな開発組織で 「開発生産性」に向き合うために試みたこと / Improving Multi-Product Dev Productivity
sugamasao
1
310
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
330
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
110
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
110
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
220
SREが投資するAIOps ~ペアーズにおけるLLM for Developerへの取り組み~
takumiogawa
1
420
TypeScript、上達の瞬間
sadnessojisan
46
13k
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
900
We Have a Design System, Now What?
morganepeng
50
7.2k
Embracing the Ebb and Flow
colly
84
4.5k
Being A Developer After 40
akosma
87
590k
Building Applications with DynamoDB
mza
90
6.1k
Designing for humans not robots
tammielis
250
25k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Six Lessons from altMBA
skipperchong
27
3.5k
A better future with KSS
kneath
238
17k
Transcript
Laravel5Ͱ Job/Queue࣮ͨ͠ גࣜձࣾRe:Build ͯͭ (Twitter: @kaoru6strings) 20193݄4ʢਫʣ Larval Meetup Okinawa
#08 https://laravel-meetup-okinawa.connpass.com/event/122396/
ࣗݾհ • த େʢͯͭ͞Μ or ͯͬͪΌΜʣ • גࣜձࣾRe:BuildɿWebΤϯδχΞ • ϦϞʔτϫʔΫͯ͠·͢
• Laravel + Vue.js, Ruby on rails @kaoru6strings
ຊJob/Queueͷ͓ @kaoru6strings
ॏ͍ॲཧผϓϩηεͰ ಈ͔͢บΛ͚ͭͯ LaravelྗΛΞοϓ͠Α͏ʂ @kaoru6strings
Job/Queueͷ͍ॴ • ϝʔϧૹ৴ • Ϣʔβͷಋઢʹؔͷͳ͍ॏ͍ͨॲཧ • ฒྻ࣮ߦ͕ඞཁͳόονॲཧ @kaoru6strings
Ϣʔβʔ͕ϒϥβ͔ΒҙͷλΠϛϯάͰ όονΛ࣮ߦ͢Δ߹ Ϣʔβͷಋઢ ͱͳΔϓϩηε @kaoru6strings ϫʔΧʔ
όονॲཧͷJobΛΩϡʔʹೖ Queue +PC +PC +PC +PC +PC
ࣄલ४උ̍ • app/Console/Kernel.phpͷscheduleʹԼهΛ Ճ • $schedule->command('queue:work --tries=1 -- timeout=0’)->withoutOverlapping(); @kaoru6strings
ࣄલ४උ̎ • crontab -e ͰԼهΛՃ • * * * *
* php /var/www/project_name/artisan schedule:run >> / dev/null 2>&1 • php artisan make:job ProcessSomething Ͱ ੜͨ͠ app/jobs/ProcessSomething.phpʹ ॲཧΛՃ @kaoru6strings
ࣄલ४උ̏ • LaravelϓϩδΣΫτͷ͓͖ͳॴʹԼهͷ ίϚϯυΛॻ͍ͯɺqueʹjobΛՃ • ProcessSomething::dispatch(); @kaoru6strings
͔͜͜Β͕ϋϚͬͨ ϙΠϯτͷհ @kaoru6strings
ࣄҊ̍: Τϥʔϩά͕ग़ྗ͞Εͳ͍ • /storage/logs/laravel.log ͷॻ͖ࠐΈݖݶΛ nginxϢʔβͷΈ͕อ͍࣋ͯͨͨ͠Ίɺϫʔ ΧʔΛ࣮ߦ͍ͯ͠ΔϢʔβ͕ΤϥʔϩάΛॻ ͖ࠐΊͣʹ͍ͨ • setfacl
-Rdm u::rwx,g::rwx,o::rwx storage @kaoru6strings
ࣄҊ̎: ্ཱͪ͛ͨϫʔΧʔ͕ͩ Μ·Γಥવࢮ͢Δ • Laravel, phpͷϩάʹԿग़ྗ͞Εͳ͍ @kaoru6strings
্ཱͪ͛ͨϫʔΧʔ͕ͩΜ·Γ ಥવࢮ͢Δ • λΠϜΞτ͍ͯ͠Δͷ͕ݪҼͩͬͨΈ͍ͨ • ϫʔΧʔ্ཱͪ͛࣌ͷίϚϯυʹԼهΦϓγϣ ϯΛࢦఆͯ͠λΠϜΞτ͠ͳ͍Α͏ʹͨ͠ • - -timeout=0
@kaoru6strings https://stackoverflow.com/questions/25877752/laravel-queue-process-timeout-error
Tips @kaoru6strings
ϫʔΧʔ͕ਖ਼ৗʹ͕͍ͨͪ͋ͬͯΔ͔֬ೝ͍ͨ͠ • ps -aef | fgrep php @kaoru6strings
ςετڥͰϫʔΧʔͷॲཧ͕ʂʂ • ·ͣਂݺٵ • ps -aef | fgrep php ͰϓϩηεidΛ֬ೝͨ͠Β
3024൪ͩͬͨ • Kill -9 3024 @kaoru6strings
Laravelͷ.envͰQUEUE_DRIVERΛઃఆ͢Δํ ๏Ͱjobͷཧํ๏ΛมߋͰ͖Δ • QUEUE_DRIVER=sync • ςετ༻ • QUEUE_DRIVER=database • Laravel͕ར༻͍ͯ͠ΔDBͰҰॹʹjobΛཧ
• QUEUE_DRIVER=redis • RedisͰjobΛཧ @kaoru6strings
վળɾٙ • ࠓճKernelʹίϚϯυΛՃͯ͠ϫʔΧʔ Λىಈͤ͞Δํ๏Λͱ͕ͬͨɺຊ SupervisorΛઃఆͨ͠΄͏͕͍͍Β͍͠ • Laravel forge(https://forge.laravel.com/)Λ ͬͨΒઃఆ͕؆୯Β͍͚͠Ͳɺͬͨ͜ ͱ͋Δਓ͍·͔͢ʁ
@kaoru6strings
ΈΜͳͰJob/Queue͓͏ʂ @kaoru6strings
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ @kaoru6strings