diff --git a/src/Illuminate/Console/Scheduling/CacheMutex.php b/src/Illuminate/Console/Scheduling/CacheMutex.php index 6ad96cfc2532..b5e7560fb42e 100644 --- a/src/Illuminate/Console/Scheduling/CacheMutex.php +++ b/src/Illuminate/Console/Scheduling/CacheMutex.php @@ -27,12 +27,12 @@ public function __construct(Cache $cache) /** * Attempt to obtain a mutex for the given event. * - * @param \Illuminate\Console\Scheduling\Event $event + * @param \Illuminate\Console\Scheduling\Event|CallbackEvent $event * @return bool */ public function create(Event $event) { - return $this->cache->add($event->mutexName(), true, 1440); + return $this->cache->add($event->mutexName(), true, $event->expiresAt); } /** diff --git a/src/Illuminate/Console/Scheduling/CallbackEvent.php b/src/Illuminate/Console/Scheduling/CallbackEvent.php index 135268745d85..e1f8e0197ec5 100644 --- a/src/Illuminate/Console/Scheduling/CallbackEvent.php +++ b/src/Illuminate/Console/Scheduling/CallbackEvent.php @@ -90,11 +90,10 @@ protected function removeMutex() /** * Do not allow the event to overlap each other. * + * @param int $expiresAt * @return $this - * - * @throws \LogicException */ - public function withoutOverlapping() + public function withoutOverlapping($expiresAt = 1440) { if (! isset($this->description)) { throw new LogicException( @@ -103,6 +102,7 @@ public function withoutOverlapping() } $this->withoutOverlapping = true; + $this->expiresAt = $expiresAt; return $this->skip(function () { return $this->mutex->exists($this); diff --git a/src/Illuminate/Console/Scheduling/Event.php b/src/Illuminate/Console/Scheduling/Event.php index 25137bfbaefa..49e3d1204656 100644 --- a/src/Illuminate/Console/Scheduling/Event.php +++ b/src/Illuminate/Console/Scheduling/Event.php @@ -64,6 +64,13 @@ class Event */ public $withoutOverlapping = false; + /** + * Mutex deadline in minutes. + * + * @var int + */ + public $expiresAt; + /** * Indicates if the command should run in background. * diff --git a/src/Illuminate/Console/Scheduling/Schedule.php b/src/Illuminate/Console/Scheduling/Schedule.php index 54e6f99dd821..41239c5affed 100644 --- a/src/Illuminate/Console/Scheduling/Schedule.php +++ b/src/Illuminate/Console/Scheduling/Schedule.php @@ -41,7 +41,7 @@ public function __construct() * * @param string|callable $callback * @param array $parameters - * @return \Illuminate\Console\Scheduling\Event + * @return \Illuminate\Console\Scheduling\CallbackEvent */ public function call($callback, array $parameters = []) { @@ -74,7 +74,7 @@ public function command($command, array $parameters = []) * Add a new job callback event to the schedule. * * @param object|string $job - * @return \Illuminate\Console\Scheduling\Event + * @return \Illuminate\Console\Scheduling\CallbackEvent */ public function job($job) {