带有AWS Elastic Beanstalk的Laravel队列 [英] Laravel Queue with AWS Elastic Beanstalk
问题描述
在我的本地服务器上,我可以毫无问题地使用队列,只需使用: php artisan queue:work
.
In my local server I can use the queue without problem, just using:
php artisan queue:work
.
但是在我的AWS服务器中,队列未运行.
But in my server in AWS the queue don't running.
我的连接队列是数据库
,同步邮件发送没有问题.
My connection queue is database
and sync mails are sending without problem.
我已在Job表中签入,可以看到我的队列,但由于未知原因,它从未运行.
I'd checked in Job table and I can see my queues but for unknown reason it's never running.
是否有必要在AWS Elastic Beanstalke服务器中进行一些不同的配置?
Is necessary to do some different configuration in AWS Elastic Beanstalke server?
我尝试手动使用
php artisan queue:listen
php artisan queue:work
都失败了.
推荐答案
要检查的内容:
-
尝试指定连接名称:
php artisan queue:work database
否则,请确保在这种情况下,EC2上的env文件引用正确的默认QUEUE_DRIVER QUEUE_DRIVER = database
Else make sure your env file on EC2 refers to correct default QUEUE_DRIVER QUEUE_DRIVER=database
in this case
如果未在环境文件中指定队列驱动程序,请检查config/queue.php的默认设置. default'=>env('QUEUE_DRIVER','database')
Check config/queue.php for right default settings, if you don't specify queue driver in env file default' => env('QUEUE_DRIVER', 'database')
在您的EC2实例上运行 php artisan config:cache
以重新加载环境更改.
Run php artisan config:cache
on your EC2 instance for reload the env changes.
您只需要使用以下2条命令之一,建议使用 php artisan queue:work
作为其缓存应用程序状态的方法,但是每运行一次 php artisan queue:restart
推送代码更改的时间.
And you only need to use only one of the 2 commands, recommended is php artisan queue:work
as its caches application state but run php artisan queue:restart
every time you push code changes.
建议安装和配置主管: https://laravel.com/docs/5.8/queues#supervisor-configuration
It is recommended to install and configure supervisor: https://laravel.com/docs/5.8/queues#supervisor-configuration
它将负责在EC2重新启动或队列故障时重新启动队列工作器
It will take care of restarting the queue worker on EC2 restart or queue failure
这篇关于带有AWS Elastic Beanstalk的Laravel队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!