首页 > 解决方案 > Laravel 队列未从 Kernel.php 读取更新

问题描述

背景

我有一个 laravel 项目,现在已经运行了好几个星期,并且每 5 分钟运行一次预定的作业,没有问题。我可以看到该作业正在 Horizo​​n 中运行,如果我使用php artisan queue:work --tries=3,我也可以看到该作业正在运行。仅供参考 - 我使用 Redis 作为队列驱动程序。

工作的 Kernel.php

namespace App\Console;

use Artisan;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Jobs\FetchMajorProblems;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        //
        'App\Console\Commands\MassAssignRole',
        'App\Console\Commands\ClearLogs',
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {

       $schedule->command('horizon:snapshot')->everyFiveMinutes();

       $schedule->job(new FetchMajorProblems)->everyFiveMinutes();

    }

    /**
     * Register the Closure based commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        require base_path('routes/console.php');
    }
}

问题

我现在创建了一份新工作,方式与我为FetchMajorProblems. 我现在还通过以下 2 个更改将其添加到 Kernel.php 文件中;

FetchMajorIncidents但是,没有调用新作业。

我试过的

我尝试了以下方法:

作为测试,我还尝试通过注释来删除当前工作$schedule->job(new FetchMajorProblems)->everyFiveMinutes();。问题是即使这被注释掉了,作业仍然每 5 分钟运行一次!

我想不出其他任何东西来检查作业可能被缓存的位置。

标签: laravelqueuehorizon

解决方案


推荐阅读