isbkch / lumen-health-checks
Make health checks in your lumen application
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 3 206
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.0.0
- illuminate/support: ~5.4|~5.3
- vistik/typed-collections: ^2.0
Requires (Dev)
- mockery/mockery: ^0.9.9
- orchestra/testbench: ~3.0
- phpmd/phpmd: ^2.6
- phpunit/phpunit: ~6.0
- squizlabs/php_codesniffer: *
This package is auto-updated.
Last update: 2020-06-30 01:28:41 UTC
README
Add health checks to your Laravel applications with this package.
Examples
Install
First, use Composer to install this package.
$ composer require isbkch/lumen-health-checks
After the package has been installed, go ahead and add ``Isbkch\ServiceProvider\HealthCheckServiceProvider::classto your
config/app.php` file.
After doing this, you can publish the health.php
configuration file into your config
folder by running:
$ $app->register(\Isbkch\ServiceProvider\HealthCheckServiceProvider::class);
$ $app->configure('health');
Usage
Inside the config/health.php
file is where you configure all your available health checks. By default, this package comes packed with a few checks already:
CorrectEnvironment
will check if your application's environment is set toproduction
DatabaseOnline
will check your database connectionDatabaseUpToDate
will check if your application has any migrations that hasn't been migrated yetDebugModeOff
will check if debug mode is offQueueProcessing
will check if the queue is running and jobs are getting processedPathIsWritable
will check if a provided path is writableLogLevel
will check if log level is set to the given valueMaxRatioOf500Responses
will check if the ratio of 500 response are above a given threshold (The last 60 min)MaxResponseTimeAvg
will check if average response time for all request are above a given threshold (The last 60 min)
To run a health check of your application, run:
$ php artisan health:check
You can also use Laravel's scheduler to schedule your health checks:
$schedule->command('health:check')->hourly();
Url based health checks
You can also run a health check by hitting the https://<APP_URL>/_health
url in a browser or with a tool like Pingdom.
Note: _This feature can be disabled in the config/health.php
file, by setting route.enabled
to false
.
You can navigate to https://<APP_URL>/_health/stats
and get all stats, including avg response time,
Creating your own health checks
In order to create your own health checks, you just need to extend the Isbkch\Checks\HealthCheck
class and implement the run()
method.
Example:
class IsFriday extends Isbkch\Checks\HealthCheck { public function run(): bool { return Carbon::now()->isFriday(); } }
Then add new IsFriday()
to the list of checks in config/health.php
.
Testing
$ phpunit tests/
Security
If you discover any security related issues, please email :author_email instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.