diff options
author | William Hubbs <w.d.hubbs@gmail.com> | 2018-10-09 17:49:02 -0500 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2018-10-23 13:38:14 -0500 |
commit | c1e582586d398b4452f568240985247294f645ef (patch) | |
tree | 5d198ed01618ed89ab04f3ab331597102d03ce99 /supervise-daemon-guide.md | |
parent | 7a75bfb00c52687a236c92bec78b5e7ab4844701 (diff) |
supervise-daemon: add health checks
Health checks are a way to monitor a service and make sure it stays
healthy.
If a service is not healthy, it will be automatically restarted after
running the unhealthy() function to clean up.
Diffstat (limited to 'supervise-daemon-guide.md')
-rw-r--r-- | supervise-daemon-guide.md | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/supervise-daemon-guide.md b/supervise-daemon-guide.md index 0b15a858..07ab55cf 100644 --- a/supervise-daemon-guide.md +++ b/supervise-daemon-guide.md @@ -22,6 +22,28 @@ The following is a brief guide on using this capability. instructs it not to fork to the command_args_foreground variable shown below. +# Health Checks + +Health checks are a way to make sure a service monitored by +supervise-daemon stays healthy. To configure a health check for a +service, you need to write a healthcheck() function, and optionally an +unhealthy() function in the service script. Also, you will need to set +the healthcheck_timer and optionally healthcheck_delay variables. + +## healthcheck() function + +The healthcheck() function is run repeatedly based on the settings of +the healthcheck_* variables. This function should return zero if the +service is currently healthy or non-zero otherwise. + +## unhealthy() function + +If the healthcheck() function returns non-zero, the unhealthy() function +is run, then the service is restarted. Since the service will be +restarted by the supervisor, the unhealthy function should not try to +restart it; the purpose of the function is to allow any cleanup tasks +other than restarting the service to be run. + # Variable Settings The most important setting is the supervisor variable. At the top of @@ -53,6 +75,20 @@ forks and goes to the background by default. This should be set to the command line option that instructs the daemon to stay in the foreground. ``` sh +healthcheck_delay=seconds +``` + +This is the delay, in seconds, before the first health check is run. +If it is not set, we use the value of healthcheck_timer. + +``` sh +healthcheck_timer=seconds +``` + +This is the number of seconds between health checks. If it is not set, +no health checks will be run. + +``` sh respawn_delay ``` |