Skip to content

Commit 4f13484

Browse files
authored
Add Health Check Guide (#177)
1 parent 6ae7df0 commit 4f13484

34 files changed

Lines changed: 582 additions & 32 deletions

File tree

docs/docs/Health-Check-Guide.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
**NOTICE:** This software (or technical data) was produced for the U.S. Government under contract,
2+
and is subject to the Rights in Data-General Clause 52.227-14, Alt. IV (DEC 2007). Copyright 2023
3+
The MITRE Corporation. All Rights Reserved.
4+
5+
6+
# Health Check Overview
7+
8+
The C++ and Python component executors can be configured to run health checks on components prior
9+
to running jobs. Health checks are configured using environment variables and an INI file. All of
10+
the log lines pertaining to the health check will be prefixed with `[Health check] -` instead
11+
of `[Job #: media] -`.
12+
13+
When the component executor receives a job from ActiveMQ, it checks if health checks are enabled
14+
and if more than the specified timeout has passed since the last health check. If both conditions
15+
are true, the component executor will run a health check job before the actual job. Health checks
16+
only run after a job from ActiveMQ is received. If the timeout period expires, but no job is
17+
received or a job is already running, the health check will not run until the next job is received.
18+
19+
If the health check job completes successfully, then the component executor runs the job received
20+
from ActiveMQ. If the health check fails, the job will be returned to ActiveMQ. If the maximum
21+
number of consecutive health check failures has not been met, the component executor will wait the
22+
timeout period before until attempting to receive another job from ActiveMQ. If the maximum number
23+
of consecutive health check failures has been met, the component executor will exit with exit
24+
code 39. If the component is running in a Docker container, the container will exit.
25+
26+
27+
# Environment Variables
28+
29+
- `HEALTH_CHECK`: When set to "ENABLED", the component executor will run health checks.
30+
- `HEALTH_CHECK_TIMEOUT`: When set to a positive integer, specifies the minimum number of seconds
31+
between health checks. When absent or set to 0, a health check will run before every job.
32+
- `HEALTH_CHECK_RETRY_MAX_ATTEMPTS`: When set to a positive integer, specifies the number of
33+
consecutive health check failures that will cause the component service to exit. When absent or
34+
set to 0, the component service will never exit because of a failed health check.
35+
36+
37+
# The INI File
38+
39+
When health checks are enabled, the component executor will look for an INI file at
40+
`$MPF_HOME/plugins/<component-name>/health/health-check.ini`. Below is an example of the expected
41+
INI file.
42+
43+
```ini
44+
media=$MPF_HOME/plugins/OcvFaceDetection/health/meds_faces_image.png
45+
min_num_tracks=2
46+
media_type=IMAGE
47+
48+
[job_properties]
49+
JOB PROP1=VALUE1
50+
JOB PROP2=VALUE2
51+
52+
[media_properties]
53+
MEDIA PROP=MEDIA VALUE
54+
```
55+
56+
The supported keys are:
57+
58+
- `media`: (Required) Path to the media file that will be used in the health check.
59+
- `min_num_tracks`: (Required) The minimum number of tracks the component must find for the health
60+
check to pass.
61+
- `media_type`: (Required) The type of media referenced in the `media` key. It must be one of
62+
"IMAGE", "VIDEO", "AUDIO", or "GENERIC".
63+
- `job_properties`: (Optional) Job properties that will set on the health check job.
64+
- `media_properties`: (Optional) Media properties that will set on the health check job.

docs/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pages:
2727
- Markup Guide: Markup-Guide.md
2828
- TiesDb Guide: TiesDb-Guide.md
2929
- Trigger Guide: Trigger-Guide.md
30+
- Health Check Guide: Health-Check-Guide.md
3031
- REST API: REST-API.md
3132
- Component Development:
3233
- Component API Overview: Component-API-Overview.md

docs/site/404.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@
114114
</li>
115115
<li class="">
116116

117+
<a class="" href="/Health-Check-Guide/index.html">Health Check Guide</a>
118+
</li>
119+
<li class="">
120+
117121
<a class="" href="/REST-API/index.html">REST API</a>
118122
</li>
119123
</ul>

docs/site/Acknowledgements/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@
124124
</li>
125125
<li class="">
126126

127+
<a class="" href="../Health-Check-Guide/index.html">Health Check Guide</a>
128+
</li>
129+
<li class="">
130+
127131
<a class="" href="../REST-API/index.html">REST API</a>
128132
</li>
129133
</ul>

docs/site/Admin-Guide/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@
143143
</li>
144144
<li class="">
145145

146+
<a class="" href="../Health-Check-Guide/index.html">Health Check Guide</a>
147+
</li>
148+
<li class="">
149+
146150
<a class="" href="../REST-API/index.html">REST API</a>
147151
</li>
148152
</ul>

docs/site/CPP-Batch-Component-API/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@
121121
</li>
122122
<li class="">
123123

124+
<a class="" href="../Health-Check-Guide/index.html">Health Check Guide</a>
125+
</li>
126+
<li class="">
127+
124128
<a class="" href="../REST-API/index.html">REST API</a>
125129
</li>
126130
</ul>

docs/site/CPP-Streaming-Component-API/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@
121121
</li>
122122
<li class="">
123123

124+
<a class="" href="../Health-Check-Guide/index.html">Health Check Guide</a>
125+
</li>
126+
<li class="">
127+
124128
<a class="" href="../REST-API/index.html">REST API</a>
125129
</li>
126130
</ul>

docs/site/Component-API-Overview/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@
121121
</li>
122122
<li class="">
123123

124+
<a class="" href="../Health-Check-Guide/index.html">Health Check Guide</a>
125+
</li>
126+
<li class="">
127+
124128
<a class="" href="../REST-API/index.html">REST API</a>
125129
</li>
126130
</ul>

docs/site/Component-Descriptor-Reference/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@
121121
</li>
122122
<li class="">
123123

124+
<a class="" href="../Health-Check-Guide/index.html">Health Check Guide</a>
125+
</li>
126+
<li class="">
127+
124128
<a class="" href="../REST-API/index.html">REST API</a>
125129
</li>
126130
</ul>

docs/site/Contributor-Guide/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@
121121
</li>
122122
<li class="">
123123

124+
<a class="" href="../Health-Check-Guide/index.html">Health Check Guide</a>
125+
</li>
126+
<li class="">
127+
124128
<a class="" href="../REST-API/index.html">REST API</a>
125129
</li>
126130
</ul>

0 commit comments

Comments
 (0)