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
55
Laravel5でJob_Queue実装した話_v1.0.1
修正版でございます
NakanishiTetsuhiro
March 06, 2019
Tweet
Share
More Decks by NakanishiTetsuhiro
See All by NakanishiTetsuhiro
コメントの書き方から見る 良いコードについての考察
nakanishitetsuhiro
0
630
SelfIntroduction
nakanishitetsuhiro
0
49
Laravelで設計する際の ベストプラクティスを探る
nakanishitetsuhiro
0
2.2k
MackerelでECS on Fargate 監視してみた
nakanishitetsuhiro
0
880
WebエンジニアによるWebエンジニアのための今だからこそおすすめしたいLinux環境
nakanishitetsuhiro
1
96
本番環境をECSで構築した話
nakanishitetsuhiro
0
900
Laravel5でjobque実装した話
nakanishitetsuhiro
0
100
社会人による社会人のための友達づくりのすゝめ
nakanishitetsuhiro
0
50
RancherにDocker初心者がチャレンジしてみた!.pdf
nakanishitetsuhiro
0
430
Other Decks in Technology
See All in Technology
American airlines ®️ USA Contact Numbers: Complete 2025 Support Guide
airhelpsupport
0
390
freeeのアクセシビリティの現在地 / freee's Current Position on Accessibility
ymrl
2
200
Operating Operator
shhnjk
1
590
fukabori.fm 出張版: 売上高617億円と高稼働率を陰で支えた社内ツール開発のあれこれ話 / 20250704 Yoshimasa Iwase & Tomoo Morikawa
shift_evolve
PRO
2
7.8k
Flutter向けPDFビューア、pdfrxのpdfium WASM対応について
espresso3389
0
130
使いたいMCPサーバーはWeb APIをラップして自分で作る #QiitaBash
bengo4com
0
2k
AIの全社活用を推進するための安全なレールを敷いた話
shoheimitani
2
530
高速なプロダクト開発を実現、創業期から掲げるエンタープライズアーキテクチャ
kawauso
2
9.4k
United airlines®️ USA Contact Numbers: Complete 2025 Support Guide
unitedflyhelp
0
310
無意味な開発生産性の議論から抜け出すための予兆検知とお金とAI
i35_267
4
13k
さくらのIaaS基盤のモニタリングとOpenTelemetry/OSC Hokkaido 2025
fujiwara3
3
450
整頓のジレンマとの戦い〜Tidy First?で振り返る事業とキャリアの歩み〜/Fighting the tidiness dilemma〜Business and Career Milestones Reflected on in Tidy First?〜
bitkey
2
16k
Featured
See All Featured
For a Future-Friendly Web
brad_frost
179
9.8k
We Have a Design System, Now What?
morganepeng
53
7.7k
Balancing Empowerment & Direction
lara
1
430
Art, The Web, and Tiny UX
lynnandtonic
299
21k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
How to train your dragon (web standard)
notwaldorf
95
6.1k
Testing 201, or: Great Expectations
jmmastey
43
7.6k
Adopting Sorbet at Scale
ufuk
77
9.5k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
RailsConf 2023
tenderlove
30
1.1k
How STYLIGHT went responsive
nonsquared
100
5.6k
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