-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App; | ||
|
||
use Laravel\Horizon\Contracts\MasterSupervisorRepository; | ||
use UKFast\HealthCheck\HealthCheck; | ||
use UKFast\HealthCheck\Status; | ||
|
||
/** | ||
* Verify Horizon is running. | ||
* | ||
* @author https://github.com/dominikager | ||
* | ||
* @source https://github.com/ans-group/laravel-health-check/issues/78#issue-1847102332 | ||
*/ | ||
class HorizonHealthCheck extends HealthCheck | ||
{ | ||
/** | ||
* The name for this health check. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'horizon'; | ||
|
||
public function __construct(private readonly MasterSupervisorRepository $supervisorRepository) | ||
{ | ||
} | ||
|
||
public function status(): Status | ||
{ | ||
$masters = $this->supervisorRepository->all(); | ||
|
||
if (count($masters) === 0) { | ||
return $this->problem('Horizon is inactive'); | ||
} | ||
|
||
return collect($masters)->contains( | ||
static fn (object $master): bool => $master->status === 'paused' | ||
) ? $this->problem('Horizon is paused') : $this->okay(); | ||
} | ||
} |
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