Symfony bundle for health checks automation, based on health check library
$ composer require oat-sa/bundle-health-check
Note: the related flex recipe will enable and auto configure the bundle in your application.
This bundle provides by default the following endpoints:
Method | Route | Description |
---|---|---|
GET |
/ping |
ensures your application is up and running (no logic) |
GET |
/health-check |
runs registered checkers (custom logic) |
Notes:
- you can check the related openapi documentation for more details
- you can update / disable those routes in the
config/routes/health_check.yaml
file of your application (created by flex recipe)
The ping endpoint just returns a 200
response with the string pong
as body.
It is just here to ensure your application is correctly installed, up and running.
This bundle will automatically add the tag health_check.checker
to your application services if they implement the CheckerInterface
(they will be auto registered onto the HealthChecker service).
If you want to register a CheckerInterface implementation from 3rd party libraries, you can configure them as following:
# config/services.yaml
services:
My\Bundle\Checker\SomeChecker:
tags:
- { name: 'health_check.checker', priority: 2 }
My\Bundle\Checker\OtherChecker:
tags:
- { name: 'health_check.checker', priority: 1 }
Note: you can use the priority
property of the health_check.checker
tag to order them.
If you prefer to run your checks in CLI mode, this bundle provides by default the following command:
$ bin/console health:check
Notes:
- it runs registered checkers as explained in section above
- it returns
0
in case of overall success, or1
if one (or more than one) checker failed - it displays a summary of all executed checkers and their result
To run provided tests:
$ vendor/bin/phpunit
Note: see phpunit file for available suites.