为什么Laravel或Beanstalkd跳过作业? [英] Why is Laravel or Beanstalkd skipping jobs?

查看:105
本文介绍了为什么Laravel或Beanstalkd跳过作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过 supervisord 监视的 Laravel队列 beanstalkd 管理音频转换.

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

当用户上传音频文件时,它会转到AudioController.php并触发Queue::push('AudioProcess'),该文件本身会触发exec('sh some_script.sh some_audio.mp3')来处理音频,并在完成后将应用程序的音频模型状态设置为1.

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表示AudioProcess.php工作程序已被执行,而0表示AudioProcess.php工作程序尚未被执行.

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

我想它可能来自Laravel Queues管理或beantalkd,但我在日志中找不到任何相关内容(laravel.log,我的主管queue.logphp_errors.log).

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).

我正在同一台服务器上运行暂存和生产环境,因此有两个Laravel应用程序,因此有两个同时运行的php artisan queue:listen命令(每个都指定了--env),如果有处理我的问题.几周前它运行良好,然后我放弃了该项目一段时间,最近又收回了该项目.我也做了apt-get update && apt-get upgrade.

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.

为什么Laravel或beantalkd无法处理所有作业?

Why is Laravel or beanstalkd not processing all jobs?

推荐答案

之所以可能出现此问题,是因为两个php artisan queue:listen(针对每个环境)正在将作业发送到相同的beantalkd队列(default).这导致了某种冲突,但我无法告诉更多...

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...

我通过使每个环境的php artisan queue:listen将作业发送到[environment]队列来解决此问题.因此,我现在有两个队列,分别是stagingproduction.

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.

操作方法

  • 创建一个app/config/[environment]/queue.php来覆盖 default中的[connections => [beanstalkd => [queue]]]参数 该环境的名称.

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

指定队列名称以 工匠:php artisan queue:listen --queue=[environment]

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

这篇关于为什么Laravel或Beanstalkd跳过作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆