Asked Sep 9th, 2021 10:26 a.m. 156 0 1
  • 156 0 1
+1

Hỏi về queue trong laravel 8

Share
  • 156 0 1

Mọi người cho em hỏi cách run toàn bộ queue trên laravel 8 với ạ . Trước em dùng laravel 7 chỉ cần 'php artisan queue:work' là đc Giờ dùng laravel 8 Run queue phải "php artisan queue:work --queue=queue1,queue2' nó mới chạy

1 ANSWERS


Answered Sep 9th, 2021 10:39 a.m.
+1

Thực tế command php artisan queue:work sẽ bật 1 worker xử lý các job trong queue default, có thể do ngày trước bạn chưa định nghĩa job chạy trong queue nào chứ không phải có sự khác biệt trong version của laravel. Để chạy nhiều worker lên thì bạn làm như trên document của Laravel là sử dụng Supervisor (https://laravel.com/docs/8.x/queues#configuring-supervisor)

[program:worker-queue-1]
process_name=%(program_name)s_%(process_num)02d
command=php /home/forge/app.com/artisan queue:work  --queue=queue1
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=forge
numprocs=8
redirect_stderr=true
stdout_logfile=/home/forge/app.com/worker-1.log
stopwaitsecs=3600

[program:worker-queue-2]
process_name=%(program_name)s_%(process_num)02d
command=php /home/forge/app.com/artisan queue:work --queue=queue2
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=forge
numprocs=8
redirect_stderr=true
stdout_logfile=/home/forge/app.com/worker-2.log
stopwaitsecs=3600
Share
Avatar Nguyen Nhat @nhatnguyen123321
Sep 9th, 2021 10:52 a.m.

@dao.thai.son như này mỗi lần thêm 1 queue là phải thêm trong file .conf rồi chạy các lệnh reload một lần

0
| Reply
Share
Avatar Dao Thai Son @dao.thai.son
Sep 10th, 2021 3:59 a.m.

@nhatnguyen123321 đúng rồi, bởi vì queue worker là 1 long-lived process nên code sẽ không thay đổi trên đó nếu như bạn không restart worker

0
| Reply
Share
Viblo
Let's register a Viblo Account to get more interesting posts.