Laravel Schedule WithoutOverlapping()无法与runInBackground()一起使用 [英] Laravel Schedule withoutOverlapping() is not working with runInBackground()

查看:294
本文介绍了Laravel Schedule WithoutOverlapping()无法与runInBackground()一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为/app/Console/Kernel.php 中的命令设置时间表,并发现 withoutOverlapping() runInBackground不兼容()

I'm trying to setup schedule for my commands in /app/Console/Kernel.php and found out that withoutOverlapping() doesnt work with runInBackground()

这可以无重叠地工作:

$schedule
    ->command('test:update')
    ->withoutOverlapping();

这与任务重叠:

$schedule
    ->command('test:update')
    ->withoutOverlapping()
    ->runInBackground();

推荐答案

在第一种情况下,它没有重叠,因为命令在前台运行,并且调度程序正在忙于处理此命令,因此直到当前才运行新命令命令完成. withoutOverlapping()在这里没有任何影响.

In the first case, it was working without overlaps because command was running in the foreground and scheduler was busy processing this command thus didn't run new one until current command finished. withoutOverlapping() did not impact anything here.

因此,问题在于互斥量不是使用 withoutOverlapping()创建的.Laravel调度程序正在将缓存用于互斥量.将缓存驱动程序切换为redis可以解决此问题,现在 withoutOverlapping()可以正常工作了.

So the problem was that the mutex is not being created withwithoutOverlapping(). Laravel scheduler is using cache for mutex. Switching cache driver to redis helped fix this issue, now withoutOverlapping() works as it should.

这篇关于Laravel Schedule WithoutOverlapping()无法与runInBackground()一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆