求助:队列任务失败后为什么没有重试呀?

1. 运行环境

1). 当前使用的 Laravel 版本?

8.75

2). 当前使用的 php/php-fpm 版本?

PHP 版本:8.0

3). 当前系统

CentOS 7

2. 问题描述?

最近写了个队列任务,再线上运行着,最近发现失败了不会自动重试啦,之前有没有重试也没注意,暂时没找到原因,请有经验的大哥给看看什么原因造成的?每次修改代码都重启supervisor啦。


class CashRewardDetail implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;


    /**
     * 任务可尝试次数.
     *
     * @var int
     */
    public $tries = 7;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct()
    {
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        if (SUCCESS) {

        } else {
            $this->fail();
            return;
        }

    }

    public function backoff()
    {
        return [2, 5, 10, 20, 30, 60];
    }
}

[program:queue]
command=/www/server/php/80/bin/php /www/wwwroot/host/artisan queue:listen --queue=多个队列名称
directory=/www/wwwroot/host/
autorestart=true
startsecs=3
startretries=3
stdout_logfile=/www/server/panel/plugin/supervisor/log/queue.out.log
stderr_logfile=/www/server/panel/plugin/supervisor/log/queue.err.log
stdout_logfile_maxbytes=2MB
stderr_logfile_maxbytes=2MB
user=www
priority=999
numprocs=1
process_name=%(program_name)s_%(process_num)02d
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
讨论数量: 3

看失败队列里面的信息,failed_jobs

1年前 评论
php artisan queue:retry all
1年前 评论

找到原因啦,任务失败不能执行:$this->fail();,要throw 一个错误才可以后续继续重试!谢谢大家!

1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!