OpenRC / openrc

The OpenRC init system
BSD 2-Clause "Simplified" License
1.42k stars 238 forks source link

healthcheck and unhealthy not being utilized when using superise-deamon #717

Open robinknaapen opened 3 weeks ago

robinknaapen commented 3 weeks ago

Description

When using the supervise-daemon I expect healthchecks to work as described in supervise-daemon-guide.md

What I found

When the process under the supervise-daemon crashes the service still has the status started. Which is technically true since the supervise-daemon respawns the process with the given settings.

When using the supervise-daemon I can not utilize the healthcheck and unhealthy functions.

Example

# /tmp/service/service
exit 1
# https://github.com/OpenRC/openrc/blob/master/supervise-daemon-guide.md
supervisor=supervise-daemon
directory="/tmp/service"
command="$directory/service"

healthcheck_timer=1

healthcheck() {
   echo "heathcheck" >> /tmp/debug
   return 1
}

unhealthy() {
   echo "unhealthy" >> /tmp/debug
}

Given the above example, I expect the healthcheck and unhealthy to be utilized. But neither is ran.

When calling healthcheck via the service command: service <service name> healtcheck the healthcheck is ran, but not the unhealthy.

robinknaapen commented 3 weeks ago

Edit:

I accidentally left the healthcheck my in test service script. This time I left the service run without crashing instantly and found that the healthcheck does run.

To my surprise, the healthcheck does not trigger after the instant crash, and neither does the unhealthy function.

I will play with the respawn variables tomorrow to see if this makes a difference and post about this later.