oat-sa/bundle-health-check

Health Check Bundle

Installs: 818

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 37

Forks: 0

Open Issues: 0

Type:symfony-bundle

1.1.0 2020-07-08 07:16 UTC

This package is auto-updated.

Last update: 2020-10-20 09:20:51 UTC


README

Symfony bundle for health checks automation, based on health check library

Table of Contents

Installation

$ composer require oat-sa/bundle-health-check

Note: related flex recipe will enable and auto configure the bundle in your application.

Usage

Available endpoints

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)

Ping

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.

Health Checker

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.

Available command

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, or 1 if one (or more than one) checker failed
  • it displays a summary of all executed checkers and their result

Tests

To run provided tests:

$ vendor/bin/phpunit

Note: see phpunit file for available suites.