Yêu cầu thg 9 9, 2021 10:26 SA 165 0 1
  • 165 0 1
+1

Hỏi về queue trong laravel 8

Chia sẻ
  • 165 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 CÂU TRẢ LỜI


Đã trả lời thg 9 9, 2021 10:39 SA
+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
Chia sẻ
Avatar Chilly @nhatnguyen123321
thg 9 9, 2021 10:52 SA

@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

Avatar Dao Thai Son @dao.thai.son
thg 9 10, 2021 3:59 SA

@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

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí