-
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.
Add clear-queues console command --------- Co-authored-by: Mark de Heij <m.deheij@vdlp.nl> Co-authored-by: Sander Beenen <sander@sbeenen.nl>
- Loading branch information
1 parent
f7ab5a0
commit 55e4182
Showing
2 changed files
with
35 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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vdlp\Horizon\Console; | ||
|
||
use Artisan; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Contracts\Config\Repository; | ||
|
||
final class ClearQueuesCommand extends Command | ||
{ | ||
public function __construct() | ||
{ | ||
$this->name = 'vdlp:horizon:clear-queues'; | ||
$this->description = 'Clears all the Horizon 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())); | ||
} | ||
} | ||
} | ||
} |