Skip to content

Commit

Permalink
Add environment option to horizon:status command to allow for livenes…
Browse files Browse the repository at this point in the history
…s check on individual environment
  • Loading branch information
PrinsFrank committed Oct 5, 2023
1 parent 56552ff commit a67af2a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Console/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class StatusCommand extends Command
*
* @var string
*/
protected $signature = 'horizon:status';
protected $signature = 'horizon:status {--environment= : The environment name}';

/**
* The console command description.
Expand All @@ -29,13 +29,20 @@ class StatusCommand extends Command
*/
public function handle(MasterSupervisorRepository $masterSupervisorRepository)
{
if (! $masters = $masterSupervisorRepository->all()) {
$masters = collect($masterSupervisorRepository->all());
if ($environment = $this->option('environment')) {
$masters->filter(function ($supervisor) use ($environment) {
return $supervisor->environment === $environment;
});
}

if ($masters->isEmpty()) {
$this->error('Horizon is inactive.');

return 1;
}

if (collect($masters)->contains(function ($master) {
if ($masters->contains(function ($master) {
return $master->status === 'paused';
})) {
$this->warn('Horizon is paused.');
Expand Down

0 comments on commit a67af2a

Please sign in to comment.