即使给出尝试计数后,Laravel 队列仍处于处理状态

尝试使用作业发送推送通知

php artisan queue:work当我运行并Supervisor继续处理单个队列项目多次时,工作人员不会抛出超时错误

当我尝试时php artisan queue:listen,它给我一个错误,60 秒后超时。

The process "'/usr/bin/php7.2' 'artisan' queue:work '' --once --queue='default' --delay=0 --memory=128 --sleep=3 --tries=0" exceeded the timeout of 60 seconds.

我可以让处理程序在 60 秒内处理所有内容,但我想解决这个问题。

我缺少什么?

工作正在消亡,没有完成,也没有失败

我在用Laravel 5.5

我与主管一起运行的命令是php artisan queue:work

php artisan queue:restart也尝试运行并重新启动主管!

主管工人日志

[2020-08-07 13:26:35] Processing: App\Jobs\SendNotifications

[2020-08-07 13:28:05] Processing: App\Jobs\SendNotifications

[2020-08-07 13:29:36] Processing: App\Jobs\SendNotifications

[2020-08-07 13:31:07] Processing: App\Jobs\SendNotifications

[2020-08-07 13:32:38] Processing: App\Jobs\SendNotifications

[2020-08-07 13:34:08] Processing: App\Jobs\SendNotifications

[2020-08-07 13:35:39] Processing: App\Jobs\SendNotifications

发送通知.php


<?php


namespace App\Jobs;


use Exception;

use Illuminate\Bus\Queueable;

use Illuminate\Contracts\Queue\ShouldQueue;

use Illuminate\Foundation\Bus\Dispatchable;

use Illuminate\Queue\InteractsWithQueue;

use Illuminate\Queue\SerializesModels;

use Redis;


class SendNotifications implements ShouldQueue

{

    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;


    public $payload;


    /**

     * The number of times the job may be attempted.

     *

     * @var int

     */

    public $tries = 3;


    /**

     * The number of seconds the job can run before timing out.

     *

     * @var int

     */

    public $timeout = 60;


    /**

     * Create a new job instance.

     *

     * @return void

     */

    public function __construct($payload)

    {

        $this->payload = $payload;

    }


    /**

     * Execute the job.

     *

     * @return void

     */

    public function handle()

    {

        try {

            $this->handleNotifications($this->payload);

        } catch (Exception $e) {

            $this->failed($e);

        }

    }


    /**

     * The job failed to process.

     *

     * @param  Exception  $exception

     * @return void

     */



弑天下
浏览 80回答 1
1回答

繁花如伊

“如果出现任何问题,作业将自动失败并重试,处理超时错误的方法是加快作业速度或增加超时时间。当发生超时时,作业会重试。因此理论上,您最终可能会运行 2 个相同的作业如果超时太低。如果作业意外崩溃并且不报告失败,这是一种恢复方法。”所以我改变了解决我的问题的建议php artisan queue:work --memory=256 --timeout=600 --tries=3。
打开App,查看更多内容
随时随地看视频慕课网APP