68publishers / health-check-microservice
Health check microservice.
Requires
- php: ^7.4
- 68publishers/environment: ^0.3.0
- 68publishers/health-check: ^0.1.2
- nette/application: ^3.0.6
- nette/bootstrap: ^3.0
- nette/di: ^3.0.3
- nette/http: ^3.0.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.19
- nette/tester: ^2.3.4
- roave/security-advisories: dev-latest
- tracy/tracy: ^2.8
Conflicts
- nette/schema: <1.1
This package is auto-updated.
Last update: 2024-11-18 06:10:29 UTC
README
💗 Really simple Nette application based on our package 68publishers/health-check
The application can be used as a standalone microservice or can be used directly from your main application.
Standalone usage
Firstly simply download the package:
$ git clone https://github.com/68publishers/health-check-microservice.git
$ cd health-check-microservice
Installation with included docker-compose
Install the application using the following script:
$ ./installer
Once the installation is successful you can edit the ENV variables in a file .env
.
Then open a file config/health_check_service_checkers.neon
and modify definitions of a service checkers according to own requirements.
Now open this URL in a browser http://localhost:8888
respectively http://localhost:8888/{HEALTH_CHECK_URL_PATH}
.
Installation without Docker
Requirements:
- Webserver (Apache/Nginx)
- PHP 7.4
- Composer
$ composer install $ cp .env.dist .env $ cp config/health_check_service_checkers.neon.dist config/health_check_service_checkers.neon
Open the file config/health_check_service_checkers.neon
and modify definitions of service checkers according to your own requirements.
You can pass parameters directly into the definition, of course. Usage of the ENV variable for service checkers is not necessary.
Also open the file .env
where you can edit the ENV variables. Variables for services like postgres
, redis
etc. can be removed if not used.
Usage inside another application
Run following command in your application
$ composer require 68publishers/health-check-microservice
Create NEON file with service checker definitions like in the standalone usage and declare the ENV variables:
HEALTH_CHECK_URL_PATH=/health HEALTH_CHECK_ARRAY_EXPORT_MODE=full HEALTH_CHECK_TEMP_DIR={{PATH TO TEMP DIR IN THE MAIN APPLICATION}} HEALTH_CHECK_LOG_DIR={{PATH TO LOG DIR IN THE MAIN APPLICATION}} HEALTH_CHECK_SERVICE_CHECKERS_CONFIG={{PATH TO CONFIG FILE IN THE MAIN APPLICATION}}
Then modify index.php
in the application:
<?php declare(strict_types=1); use App\Bootstrap as AppBootstrap; use SixtyEightPublishers\HealthCheckMicroservice\Bootstrap as HealthCheckBootstrap; use Nette\Application\Application; require __DIR__ . '/../vendor/autoload.php'; $configurator = '/health' === $_SERVER['REQUEST_URI'] ? HealthCheckBootstrap::boot() : AppBootstrap::boot(); $configurator->createContainer() ->getByType(Application::class) ->run();
That's all, a health check endpoint will be accessible on the address domain.com/health
:)
ENV Variables
Contributing
Before committing any changes, don't forget to run
$ composer run php-cs-fixer
and
$ composer run tests