-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] add
schedule:clear-mutex
command (#40135)
* add clear mutex command * formatting * alphabetize Co-authored-by: Bernard Wiesner <[email protected]> Co-authored-by: Taylor Otwell <[email protected]>
- Loading branch information
1 parent
994dbac
commit c3ce974
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/Illuminate/Console/Scheduling/ScheduleClearCacheCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Illuminate\Console\Scheduling; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class ScheduleClearCacheCommand extends Command | ||
{ | ||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'schedule:clear-cache'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Delete the cached mutex files created by scheduler'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @param \Illuminate\Console\Scheduling\Schedule $schedule | ||
* @return void | ||
*/ | ||
public function handle(Schedule $schedule) | ||
{ | ||
$mutexCleared = false; | ||
|
||
foreach ($schedule->events($this->laravel) as $event) { | ||
if ($event->mutex->exists($event)) { | ||
$this->line('<info>Deleting mutex for:</info> '.$event->command); | ||
|
||
$event->mutex->forget($event); | ||
|
||
$mutexCleared = true; | ||
} | ||
} | ||
|
||
if (! $mutexCleared) { | ||
$this->info('No mutex files were found.'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters