Laravel 6.0,排队的作业不在服务器上排队

时间:2020-01-14 19:31:41

标签: linux laravel queue supervisord

我的视频创建过程大约需要3-5分钟。我已经使用Laravel EventsListenersQueues

作为后台任务完成了它

更改

.env文件中

QUEUE_CONNECTION=database

在数据库中创建了jobsfailed_jobs表。

CreateVideoEvent

<?php

namespace App\Events;

class CreateVideoEvent
{

    public $video_data;

    public function __construct($video_data)
    {
        $this->video_data = $video_data;
    }
}

CreateVideoListener

<?php

namespace App\Listeners;

use App\Events\CreateVideoEvent;
use Illuminate\Contracts\Queue\ShouldQueue;

class CreateVideoListener implements ShouldQueue
{

    public function __construct()
    {
        //
    }

    public function handle($event)
    {
        // Run video create commands
    }
}

主管

[program:laravel-queue]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/project_folder/artisan queue:work --tries=5 --timeout=600
autostart=true
autorestart=true
user=root
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/project_folder/worker.log

当视频创建过程开始时,它将向DB添加一个事件和一个队列作业。

event(new CreateVideoEvent($video_data));

所以,问题是当第一项工作开始工作时(大约需要3-5分钟),而我在第一个视频完成之前就创建了第二个视频,它在第一个视频开始之前就开始了第二个视频创建过程完成了。因此,基本上,作业没有排队,并且由于两个视频创建过程都停止工作,因此会引起问题。

也许我错过了一些东西,或者您知道这可能是什么原因吗?

0 个答案:

没有答案