问题
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