Laravel Schedule withoutOverlapping() is not working with runInBackground()

痞子三分冷 提交于 2021-01-28 05:13:06

问题


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

This works without overlaps:

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

This overlaps tasks:

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

回答1:


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.

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.



来源:https://stackoverflow.com/questions/60324548/laravel-schedule-withoutoverlapping-is-not-working-with-runinbackground

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!