Docker Healthcheck
Docker has a concept of "health checks", which is a way for Docker containers to tell the Docker runtime engine that the container is alive and well.
Butler SOS can be configured to send such health check messages to Docker.
Optional
These settings are optional.
If you don't need this feature just disable it and leave the default values in the config as they are.
Do note though that Butler SOS expects the configuration properties below to exist in the config file, but will ignore their values if the related features are disabled.
Note
Sending health check messages is only meaningful when running Butler SOS as a Docker container.
Settings in Main Config File
Butler-SOS:
...
...
# Docker health checks are used when running Butler SOS as a Docker container.
# The Docker engine will call the container's health check REST endpoint with a set interval to determine
# whether the container is alive/well or not.
# If you are not running Butler SOS in Docker you can safely disable this feature.
dockerHealthCheck:
enable: true # Control whether a REST endpoint will be set up to serve Docker health check messages
port: 12398 # Port the Docker health check service runs on (if enabled)
...
...The config template has the endpoint turned off (enable: false).
How the image's healthcheck uses these settings
Changed in 15.4.0
Before Butler SOS 15.4.0, the Docker image's healthcheck always asked port 12398, whatever the config file said.
The Docker image has a built-in healthcheck, which Docker runs every 12 seconds to decide whether the container is healthy or unhealthy. It reads the dockerHealthCheck settings from the config file Butler SOS was started with, the file -c or --configfile names, and acts on them:
Butler-SOS.dockerHealthCheck | What the healthcheck does |
|---|---|
enable: true | Asks the endpoint on the configured port. The container is healthy when Butler SOS answers. |
enable: false | Reports the container healthy. With the endpoint off there is nothing to ask, so Docker can't tell whether Butler SOS is doing its job. |
| The config file can't be found or read | Asks port 12398, as before. |
There is nothing to set beyond what is already in the config file.
The healthcheck's result is in the container's health log, for example:
docker inspect --format '{{range .State.Health.Log}}{{.Output}}{{end}}' butler-sos
Docker health: 200 from port 18000 (config file /nodeapp/config/production.yaml).Before 15.4.0, the healthcheck went wrong in two common cases:
- The default config. The config template has the endpoint turned off (
Butler-SOS.dockerHealthCheck.enable: false). Nothing answered on port 12398, so a container that was working fine was marked unhealthy after 30 seconds. - Another port. With
Butler-SOS.dockerHealthCheck.portset to anything but 12398, the container was marked unhealthy too.
Anything that acts on a container's health treats an unhealthy container as broken: restart policies in orchestrators, depends_on: condition: service_healthy in Docker Compose, and uptime monitoring. The Docker Compose examples turn the endpoint on at port 12398, so they were not affected.
What to do
- For a healthcheck that tells you something, turn the endpoint on:
Butler-SOS.dockerHealthCheck.enable: true. Any free port works. The healthcheck follows it. - With
--on-invalid-config wait: while Butler SOS waits on an invalid config, its endpoint is not started. With the endpoint turned on in the config, the container is reported unhealthy, which is intended. With it turned off, the container is reported healthy, as with any config that turns it off. See Staying up on an invalid config file.