【问题标题】:How to toggle laravel queue from running or not如何切换 laravel 队列的运行与否
【发布时间】:2019-09-12 17:13:38
【问题描述】:

我刚刚将自己的维护模式称为 ApplicationMaintenanceMode 扩展了 CheckForMaintenanceMode。

class ApplicationMaintenanceMode extends CheckForMaintenanceMode
{
    ....
}

并且还扩展了Application类

use Illuminate\Foundation\Application as App;
class Application extends App
{
    ....
    ....
    public function isApplicationDownForMaintenance()
    {
        //code
    }
}

然后,我也像原来一样创建自己的 DownCommand

class DownCommand extends Command
{    
    protected $signature = 'app_down {--message= : The message for the maintenance mode. }
                 {--retry= : The number of seconds after which the request may be retried.}
                 {--only=* : Routes to be include from maintenance mode.}
                 {--type=* : Type of maintenance mode.}
                 {--except=* : Routes to be exclude from maintenance mode.}
                 {--version_allow= : Application Version allowed.}
                 {--lock_queue=false : Application Queue need to run or not.}
                 {--allow=* : IP or networks allowed to access the application while in maintenance mode.}';
}

如您所见 --lock_queue 我想在哪里切换队列工作者可以运行或不运行。目的是在原来的维护模式下,它停止所有的队列。我想要实现的是我希望队列可以在维护模式下轻松切换以运行或不运行。

有什么办法吗?我应该覆盖 QueueManager 和 Worker 类吗?

【问题讨论】:

    标签: laravel laravel-5 queue laravel-queue horizon


    【解决方案1】:

    您需要在队列工作者中添加--force 标志以强制队列在维护模式下运行。

    php artisan queue:work --force
    

    您需要停止所有队列工作人员,然后根据您的要求添加此标志。

    见:https://divinglaravel.com/queue-workers-how-they-work

    【讨论】:

    • 我正在使用主管顺便说一句。
    猜你喜欢
    • 1970-01-01
    • 2017-08-14
    • 1970-01-01
    • 2016-01-20
    • 2015-02-12
    • 2017-01-14
    • 2020-03-17
    • 2016-04-03
    • 2016-10-06
    相关资源
    最近更新 更多