Laravel 5 运行队列:按 Laravel 计划工作

par*_*oid 3 php laravel laravel-5 laravel-queue laravel-scheduler

我有一个这样的时间表:

<?php

namespace App\Console;

use Illuminate\Support\Facades\Artisan;
use Illuminate\Console\Scheduling\Schedule;
protected function schedule(Schedule $schedule)
{
   Artisan::call('queue:work');
}
Run Code Online (Sandbox Code Playgroud)

我在我的 cronjob 上添加了这个:

* * * * * cd /var/www/html/my_script_address && php artisan schedule:run

它是正确的代码吗?我在问,因为每一分钟都在奔跑Artisan::call('queue:work')

这是最好的方法吗?

小智 5

您的队列工作者应该自己运行。您应该使用 supervisor 来确保它保持运行。但是,如果您必须从调度程序启动队列工作程序,最好使用queue:work --stop-when-empty