olssonm/horizon-status

Utility to check the status of Lavarel Horizon instances programmatically

v1.2 2024-03-24 15:18 UTC

This package is auto-updated.

Last update: 2024-10-24 16:37:32 UTC


README

Latest Version on Packagist Build Status Software License

Laravel Horizon status checker

Simple utility to check the current status of your Laravel Horizon instance programatically.

Why?

Why use this package if the Artisan command horizon:status is available? Because there are times that the need to check the status programatically emerge. For example, if you via scheduling want to make sure that your Horizon-instance is running and you don't want to parse strings or the like:

// app/Console/Commands/HorizonIsRunning.php
use Olssonm\HorizonStatus\Facade\HorizonStatus;

public function __handle() {
    if(!HorizonStatus::isActive()) {
        // Notify admin (not via the Horizon-queue of course...)
    }
}

// app/Console/Kernel.php
protected function schedule(Schedule $schedule) {
    $schedule->command('horizon:is-running')->everyFiveMinutes();
}

Or perhaps you want to have a status-icon clearly visible directly in your blade-template:

@if(HorizonStatus::isActive())
    <div class="success">Horizon is running</div>
@else
    <div class="warning">Horizon is down</div>
@endif

Installation

composer require olssonm/horizon-status

Note – This package requires Laravel Horizon running on either Laravel 8 or 9.

Usage

There are four methods available with this package.

status

Returns one of the three available statuses, active, inactive or paused.

use Olssonm\HorizonStatus\Facade\HorizonStatus;

HorizonStatus::status();
// active

isActive

Return true or false whether status is active:

use Olssonm\HorizonStatus\Facade\HorizonStatus;

HorizonStatus::isActive();
// true

isInactive

Return true or false whether status is inactive:

use Olssonm\HorizonStatus\Facade\HorizonStatus;

HorizonStatus::isInactive();
// false

isPaused

Return true or false whether status is paused:

use Olssonm\HorizonStatus\Facade\HorizonStatus;

HorizonStatus::isPaused();
// false

License

The MIT License (MIT). Please see the LICENSE.md for more information.

© 2022 Marcus Olsson.