【问题标题】:Laravel Queue with AWS Elastic Beanstalk使用 AWS Elastic Beanstalk 的 Laravel 队列
【发布时间】:2020-03-03 09:50:09
【问题描述】:

在我的本地服务器中,我可以毫无问题地使用队列,只需使用: php artisan queue:work.

但在我的 AWS 服务器中,队列没有运行。

我的连接队列是database,同步邮件发送没有问题。

我检查了作业表,我可以看到我的队列,但由于未知原因它从未运行。

是否需要在 AWS Elastic Beanstalke 服务器中进行一些不同的配置?

我试过手动使用

php artisan queue:listen
php artisan queue:work

都失败了。

【问题讨论】:

  • 他们失败的原因是什么?
  • @mrhn 当我使用命令并且只是“冻结”我的终端并且不运行队列时。
  • 您可以设置一个 systemd 服务来重新启动部署队列。此question 中给出的说明
  • @ThiagoValente:你在哪里运行了这些命令php artisan queue:work

标签: laravel amazon-web-services amazon-elastic-beanstalk laravel-queue


【解决方案1】:

检查事项:

  1. 尝试指定连接名称:php artisan queue:work database

  2. 在这种情况下,请确保您在 EC2 上的 env 文件引用正确的默认 QUEUE_DRIVER QUEUE_DRIVER=database

  3. 检查 config/queue.php 以获得正确的默认设置,如果您未在 env 文件default' => env('QUEUE_DRIVER', 'database') 中指定队列驱动程序@

  4. 在您的 EC2 实例上运行 php artisan config:cache 以重新加载环境更改。

您只需要使用这两个命令之一,推荐使用php artisan queue:work 作为其缓存应用程序状态,但每次推送代码更改时运行php artisan queue:restart

建议安装配置supervisor:https://laravel.com/docs/5.8/queues#supervisor-configuration

它将负责在 EC2 重新启动或队列失败时重新启动队列工作程序

【讨论】:

  • 你的清单对我有用。我的队列不工作只是因为我没有使用 php artisan config:cache。发出这个命令后,我的队列就像一个魅力。非常感谢
猜你喜欢
  • 2018-07-26
  • 2014-08-02
  • 2019-09-25
  • 2021-02-16
  • 2016-10-26
  • 2019-04-03
  • 2020-08-27
  • 2015-09-26
  • 2015-02-10
相关资源
最近更新 更多