Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Scheduling/CacheMutex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Console/Scheduling/CallbackEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -103,6 +102,7 @@ public function withoutOverlapping()
}

$this->withoutOverlapping = true;
$this->expiresAt = $expiresAt;

return $this->skip(function () {
return $this->mutex->exists($this);
Expand Down
7 changes: 7 additions & 0 deletions src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Scheduling/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [])
{
Expand Down Expand Up @@ -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)
{
Expand Down