Skip to content

Commit

Permalink
Add exit codes to status command (#1191)
Browse files Browse the repository at this point in the history
* Add exit codes to status command

* StyleCI
  • Loading branch information
mbardelmeijer authored Sep 26, 2022
1 parent 049f65d commit de84bf8
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/Console/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,26 @@ class StatusCommand extends Command
* Execute the console command.
*
* @param \Laravel\Horizon\Contracts\MasterSupervisorRepository $masterSupervisorRepository
* @return void
* @return int
*/
public function handle(MasterSupervisorRepository $masterSupervisorRepository)
{
$this->line($this->currentStatus($masterSupervisorRepository));
}

/**
* Get the current status of Horizon.
*
* @param \Laravel\Horizon\Contracts\MasterSupervisorRepository $masterSupervisorRepository
* @return string
*/
protected function currentStatus(MasterSupervisorRepository $masterSupervisorRepository)
{
if (! $masters = $masterSupervisorRepository->all()) {
return 'Horizon is inactive.';
$this->error('Horizon is inactive.');

return 1;
}

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

return 1;
}

$this->info('Horizon is running.');

return 0;
}
}

0 comments on commit de84bf8

Please sign in to comment.