如果发生故障,我想在 laravel 调度程序中重新运行作业,假设如下:
Kernal.php
protected function schedule(Schedule $schedule)
{
$this->generateData($schedule);
}
protected function generateData($schedule){
$schedule->command('My Command')
->monthly()
->after(function ($schedule){
$command = DB::table('commands')
->where("name","My Command")
->orderBy('id', 'desc')
->first();
if(!$command->succeeded){
echo "task not finished";
$this->generateData($schedule);
}
else{
echo "task finished";
return;
}
});
}
这个命令有时会失败,在函数之后我检查命令是否失败,然后我尝试再次重新执行它,但这不起作用,我收到以下错误:
[ErrorException] Missing argument 1 for App\Console \Kernel::App\Console{闭包}()
有什么建议么 ?