-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ULM-403 Add clear all horizon-queues command
- Loading branch information
Mark de Heij
committed
Sep 27, 2024
1 parent
f7ab5a0
commit 912af86
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
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
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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vdlp\Horizon\Console; | ||
|
||
use Artisan; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Contracts\Config\Repository; | ||
|
||
final class ClearAllQueuesCommand extends Command | ||
{ | ||
public function __construct() | ||
{ | ||
$this->name = 'vdlp:horizon:clear-queues'; | ||
$this->description = 'Clears all the queues with one command'; | ||
|
||
parent::__construct(); | ||
} | ||
|
||
public function handle(Repository $config): void | ||
{ | ||
$supervisors = $config->get('horizon.defaults'); | ||
|
||
foreach ($supervisors as $supervisor) { | ||
foreach ($supervisor['queue'] as $queue) { | ||
Artisan::call('horizon:clear', ['--queue' => $queue]); | ||
$this->comment(preg_replace('/\R+/', ' ', Artisan::output())); | ||
} | ||
} | ||
} | ||
} |