@@ -6,7 +6,7 @@ A Symfony 5/6/7 bundle that adds an /internal/health and /internal/info endpoint
66
77The endpoints return JSON responses. The ` /internal/info ` endpoint tries to give as much information about the currently installed
88version of the application as possible. This information is based on the build path of the installation. But also
9- includes the Symfony environment that is currently active and whether or not the debugger is enabled.
9+ includes the Symfony environment that is currently active and whether the debugger is enabled.
1010
1111The ` /internal/health ` endpoint reports on the health of the application. This information could be used for example by a load
1212balancer. Example output:
@@ -46,9 +46,11 @@ When a health check failed the HTTP Response status code will be 503. And the JS
4646 * Include the routing configuration in `config/routes.yaml` by adding:
4747 ```yaml
4848 open_conext_monitor:
49- resource: "@OpenConextMonitorBundle/Resources/config/routing.yml"
50- prefix: /
49+ resource: "@OpenConextMonitorBundle/src/Controller"
50+ type: attribute
51+ prefix: /
5152 ```
53+ _Note: this is currently done by the bundle itself, with an external dependency called https://github.com/endroid/installer_
5254
5355 * Add security exceptions in `config/packages/security.yaml` (if this is required at all)
5456 ```yaml
@@ -78,24 +80,18 @@ use OpenConext\MonitorBundle\Value\HealthReport;
7880
7981class ApiHealthCheck implements HealthCheckInterface
8082{
81- /**
82- * @var MyService
83- */
84- private $testService;
85-
86- public function __construct(MyService $service)
83+ public function __construct(private readonly MyService $service)
8784 {
88- $this->testService = $service;
8985 }
9086
9187 public function check(HealthReportInterface $report): HealthReportInterface
9288 {
93- if (!$this->testService ->everythingOk()) {
89+ if (!$this->service ->everythingOk()) {
9490 // Return a HealthReport with a DOWN status when there are indications the application is not functioning as
9591 // intended. You can provide an optional message that is displayed alongside the DOWN status.
9692 return HealthReport::buildStatusDown(' Not everything is allright.' );
9793 }
98- // By default return the report that was passed along as a parameter to the check method
94+ // By default, return the report that was passed along as a parameter to the check method
9995 return $report;
10096 }
10197}
@@ -104,35 +100,20 @@ class ApiHealthCheck implements HealthCheckInterface
104100registered health checkers. If everything was OK, just return the report that was passed to the method.
105101
106102### Register the checker
107- To actually include the home made checker simply tag it with ' surfnet.monitor.health_check'
108-
109- Example service definition in `services.yml`
110-
111- ```yaml
112- services:
113- acme.monitor.my_custom_health_check:
114- class: Acme\AppBundle\HealthCheck\MyCustomHealthCheck
115- arguments:
116- - @test_service
117- tags:
118- - { name: surfnet.monitor.health_check }
119- ```
103+ By implementing the `HealthCheckInterface` you can register your own health check.
104+ This interface is tagged automatically, so you don' t have to do it yourself.
120105
121106# # Overriding a default HealthCheck
122107To run a custom query with the DoctrineConnectionHealthCheck you will need to override it in your own project.
123108
124- For example in your ACME bunde that is using the monitor bundle:
109+ For example in your ACME bundle that is using the monitor bundle:
125110
126- `services.yml `
111+ ` services.yaml `
127112` ` ` yaml
128- # Override the service, service names can be found in `/src/Resources/ config/services.yml `
129- openconext.monitor.database_health_check :
113+ # Override the service in `/src/config/services.yaml `
114+ OpenConext \M onitorBundle \H ealthCheck \D octrineConnectionHealthCheck :
130115 # Point to your own implementation of the check
131116 class: Acme\G reatSuccessBundle\H ealthCheck\D octrineConnectionHealthCheck
132- # Do not forget to apply the correct tag
133- tags:
134- - { name: openconext.monitor.health_check }
135-
136117` ` `
137118
138119The rest of the service configuration is up to your own needs. You can inject arguments, factory calls and other service features as need be.
0 commit comments