Why is Laravel or Beanstalkd skipping jobs?

大兔子大兔子 提交于 2019-12-10 15:29:53

问题


I'm managing audio conversions with Laravel Queues and beanstalkd, monitored by supervisord.

When a user upload an audio file, it goes to AudioController.php that triggers a Queue::push('AudioProcess'), that itself triggers an exec('sh some_script.sh some_audio.mp3') to process the audio and set the application Audio model status to 1 when it's done.

I did a bunch of uploads to test, here are the records

1 means the AudioProcess.php worker has been executed and 0 means the AudioProcess.php worker hasn't been executed.

I guess it might come from either Laravel Queues management or beanstalkd, but I can't find anything relevant in the logs (laravel.log, my supervisord queue.log, php_errors.log).

I'm running a staging and a production environment on the same server, so there are two Laravel applications and therefore two php artisan queue:listen commands running at the same time (each with --env specified), if it has something to do with my issue. It worked well few weeks ago, then I dropped the project for a while and recaught it lately. I did some apt-get update && apt-get upgrade too.

Why is Laravel or beanstalkd not processing all jobs?


回答1:


The issue was likely happening because the two php artisan queue:listen (for each environment) were sending jobs to the same beanstalkd queue (default). It resulted in some kind of conflict, but I can't tell more...

I fixed it by making each environment's php artisan queue:listen send jobs to a [environment] queue. Therefore I have now two queues, staging and production.

How to do it

  • Create a app/config/[environment]/queue.php that overwrites the [connections => [beanstalkd => [queue]]] parameter from default to the name of that environment.

  • Specify the name of the queue to Artisan: php artisan queue:listen --queue=[environment]



来源:https://stackoverflow.com/questions/26834623/why-is-laravel-or-beanstalkd-skipping-jobs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!