1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00

fix(docker): the health check covers the worker and the console services

The container's health check only fetched the login page, through nginx
and gunicorn. A job worker, novncd or socketiod that kept failing (runit
starts it again each second) left the container healthy while jobs
waited and consoles failed. The check now also asks runit for each
service and fails when one is down or has run for less than five
seconds.
This commit is contained in:
catborise 2026-11-06 09:07:49 +03:00
parent e448e60684
commit 77f85832c9
2 changed files with 19 additions and 3 deletions

14
conf/runit/healthcheck Executable file
View file

@ -0,0 +1,14 @@
#!/bin/sh
# Docker's health check: the panel answers through nginx, and every service
# has run for a few seconds. runit starts a failing service again each
# second, so one that keeps failing (the worker, novncd, socketiod) is never
# up that long.
/srv/webvirtcloud/venv/bin/python3 -c "import urllib.request as u; u.urlopen(u.Request('http://127.0.0.1/accounts/login/', headers={'X-Forwarded-Proto': 'https'}), timeout=5)" || exit 1
for service in nginx webvirtcloud webvirtcloud-worker novnc socketiod; do
# "run: /etc/service/novnc: (pid 60) 45556s"
uptime=$(sv status "/etc/service/$service" | sed -n 's/^run: [^)]*) \([0-9]*\)s.*/\1/p')
if [ -z "$uptime" ] || [ "$uptime" -lt 5 ]; then
echo "$service is not running steadily: $(sv status "/etc/service/$service")"
exit 1
fi
done