tseguier/health-check

A bundle that provides a healtcheck route, with an extendable interface for your own checkers services.

This package's canonical repository appears to be gone and the package has been frozen as a result.

Installs: 420

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 2

Open Issues: 8

Type:symfony-bundle

v0.2.2 2019-08-14 17:18 UTC

This package is auto-updated.

Last update: 2019-09-23 11:58:20 UTC


README

A controller which checks all the containers implementing HealthCheckInterface. It will call the checkHealth method of each and will display a JSON output: { "status": true if all containers returned a HealthData with status true, false else. "timestamp": actual date }

Installation

Install with composer:

composer require tseguier/health-check

Add the bundle to your bundles.php

Tseguier\HealthCheckBundle\HealthCheckBundle::class => ['all' => true],

Configure the controller route in your routes.yaml

health_check:
  resource: "@HealthCheckBundle/Controller/HealthCheckController.php"
  prefix: /
  type: annotation

Configuration

The timestamp format can be configured in the date_format configuration field, default is 'Y-m-d H:i:s T'

Health Checker Services

To check the health of a service you just need to implements HealthCheckInterface into it.

e.g. :

use Tseguier\HealthCheckBundle\Dto\HealthData;
use Tseguier\HealthCheckBundle\HealthCheckInterface;

final class HealthCheckerService implements HealthCheckInterface
{

    public function checkHealth(): HealthData
    {
        if ($this->somethingToCheck->isWorking()) {
          return new HealthData(true);
        } else {
          return new HealthData(false);
        }
    }
}

Next Release

  • additional data on checked services
  • route for detailled informations