|
| 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. |
0 commit comments