Laravel非重叠计划作业未执行 [英] Laravel non-overlapping scheduled job not executing
问题描述
我有一个Laravel Scheduled作业,它在Kernel.php
中定义,就像这样
I have a Laravel Scheduled job which is defined in Kernel.php
like so
$schedule->call('\App\Http\Controllers\ScheduleController@processQueuedMessages')
->everyFiveMinutes()
->name('process_queued_messages')
->withoutOverlapping();
在开发过程中,由于语法错误,我的工作引发了异常.我更正了该错误,然后尝试再次执行该错误;但由于某种原因,它不会.
During development, my job threw an exception due to a syntax error. I corrected the error and tried executing it again; but for some reason it won't.
我尝试了artisan down
,然后尝试了artisan up
.我也尝试过重新启动服务器实例.但是没有任何帮助.作业只是没有执行(也没有例外).
I tried artisan down
and then artisan up
. I also tried restarting the server instance. But nothing would help. The job just didn't get executed (there was no exception either).
我意识到问题出在->withoutOverlapping()
上. Laravel调度程序以某种方式认为该作业已经在运行,因此不再执行.
I realize that the problem is due to ->withoutOverlapping()
. Somehow, Laravel scheduler is thinking that the job is already running and hence is not executing it again.
推荐答案
我通过查看供应商代码找到了解决方案.
I found the solution by looking at the vendor code.
Illuminate\Console\Scheduling\CallbackEvent.php
它将在本地存储中创建一个名为schedule-*
的文件.
It creates a file in local storage with the name schedule-*
.
public function withoutOverlapping()
{
if ( ! isset($this->description))
{
throw new LogicException(
"A scheduled event name is required to prevent overlapping. Use the 'name' method before 'withoutOverlapping'."
);
}
return $this->skip(function()
{
return file_exists($this->mutexPath());
});
}
protected function mutexPath()
{
return storage_path().'/framework/schedule-'.md5($this->description);
}
在storage/framework
处删除文件schedule-*
解决了该问题.
Deleting the file schedule-*
at storage/framework
resolved the issue.
这篇关于Laravel非重叠计划作业未执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!