Adds health checks to web and data_handler container; restarting on failure #24

Merged
stb merged 17 commits from healthcheck into main 2026-11-15 14:32:36 +01:00
Collaborator

Increases the resilience of most containers a bit:
fd6b1d680c: web health check verifies the camera endpoint returns at least one position when zoomed all the way out (shows most of Europe and parts of Asia)
58f048adba: Adding a health check to data_handler required more verbose output; before this PR, all logs generated by dcrond and its jobs were silenced; they're now stored in /var/log
f94080f45f: Previously, update_camera.sh was only started every hour at xx:05; now it's also run immediately after the container starts
73e9c279df: Adds a health check to data_handler, which remains healthy unless the newest update_camera_ log file contains the word error
82b41342fc: Restarts any container if the associated health check fails (shutdowns by users still allowed)

Increases the resilience of most containers a bit: fd6b1d680c: `web` health check verifies the camera endpoint returns at least one position when zoomed all the way out (shows most of Europe and parts of Asia) 58f048adba: Adding a health check to `data_handler` required more verbose output; before this PR, all logs generated by `dcrond` and its jobs were silenced; they're now stored in `/var/log` f94080f45f: Previously, `update_camera.sh` was only started every hour at `xx:05`; now it's also run immediately after the container starts 73e9c279df: Adds a health check to `data_handler`, which remains `healthy` unless the newest `update_camera_` log file contains the word `error` 82b41342fc: Restarts any container if the associated health check fails (shutdowns by users still allowed)
first changes for sync of instances
Some checks failed
images.yml / first changes for sync of instances (push) Failing after 0s
ea2d8ebe37
modified health check for web
Some checks failed
images.yml / modified health check for web (push) Failing after 0s
images.yml / modified health check for web (pull_request) Failing after 0s
5ff2918d07
chore: Applies docker naming convention to files
docs: Adds information about changes when running in a development environment
Some checks failed
images.yml / docs: Adds information about changes when running in a development environment (push) Failing after 0s
images.yml / docs: Adds information about changes when running in a development environment (pull_request) Failing after 0s
34339b8021
Author
Collaborator
  • 729af9ced9 applys the changes from #25 to the production healthcheck in docker-compose.yml. I noticed the health check never failed, as curl just asserts the 200 status code and doesn't care about the JSON content; I made it return 503 as well
  • 590fb8647a resolves an issue where new mysqli would fail if the database wasn't online; it would return the error JSON if the DB was available but the credentials were incorrect, but an offline databse host would throw before if($mysqli->connect_errno) got evaluated; I just wrapped the whole thing in a try/catch block and returned any and all errors as 503 with {"error":"Database unavailable"}
  • As Docker uses .dev.yml for most files, I applied that convention in adab9b3175; I also removed all redundant entries, so we share most of the configuration with production and development environments only override what they need in docker-compose.dev.yml
  • 34339b8021 adds these instructions (and its consequences) to README.MD
  • 907c20bad2 adds APP_ENV=development when running .dev.yml and makes the app stop silencing errors while developing by default (tracing the SQL issue without was a bit difficult : D), and it's a one-line change to re-enable error silencing that's documented in the README
- 729af9ced9520f20c58bb45e5e02faea02212ab5 applys the changes from #25 to the production healthcheck in `docker-compose.yml`. I noticed the health check never failed, as curl just asserts the `200` status code and doesn't care about the JSON content; I made it return 503 as well - 590fb8647ab1b806a1598e020d81d4718332cd01 resolves an issue where `new mysqli` would fail if the database wasn't online; it would return the error JSON if the DB was available but the credentials were incorrect, but an offline databse host would throw before `if($mysqli->connect_errno)` got evaluated; I just wrapped the whole thing in a try/catch block and returned any and all errors as `503` with `{"error":"Database unavailable"}` - As Docker uses `.dev.yml` for most files, I applied that convention in adab9b31756a78180d209f7fd4ef86e2a0eaeb71; I also removed all redundant entries, so we share most of the configuration with production and development environments only override what they need in `docker-compose.dev.yml` - 34339b8021b14ee91cc744a59130e40210f46688 adds these instructions (and its consequences) to `README.MD` - 907c20bad29414d8d41f51503cebe9454d561c5c adds `APP_ENV=development` when running `.dev.yml` and makes the app stop silencing errors while developing by default (tracing the SQL issue without was a bit difficult : D), and it's a one-line change to re-enable error silencing that's documented in the README
fix: Adds missing documentation hint for secret replacement
Some checks failed
images.yml / fix: Adds missing documentation hint for secret replacement (push) Failing after 0s
images.yml / fix: Adds missing documentation hint for secret replacement (pull_request) Failing after 0s
c2a8412c4b
revert: Uses previous port mapping
Some checks failed
images.yml / revert: Uses previous port mapping (push) Failing after 0s
images.yml / revert: Uses previous port mapping (pull_request) Failing after 0s
e601c6df58
Merge remote-tracking branch 'origin/main' into healthcheck
Some checks failed
Build (and tag) Images / build (push) Failing after 12s
27685701c7
# Conflicts:
#	docker-compose.yml
Merge remote-tracking branch 'origin/main' into healthcheck
Some checks failed
Build (and tag) Images / build (push) Has been cancelled
8ebf9a5cf1
stb requested changes 2026-11-15 11:56:20 +01:00
Dismissed
@ -9,3 +9,3 @@
cat<<EOF | dcrontab -
# min hour day month weekday command
5 * * * * sh /opt/update_camera.sh
*/15 * * * * sh /opt/update_camera.sh >> /var/log/update_camera_$(date +\%Y\%m\%d\%H\%M\%S).log 2>&1
Owner

Füllt das nicht die Platte? Warum nicht einfach nach /dev/console, dann landet es im Container-Log?

Füllt das nicht die Platte? Warum nicht einfach nach /dev/console, dann landet es im Container-Log?
Author
Collaborator

Der Health-Check liest die. Ich habs 5ce403cec2 in ein Status-File umgebogen, dass nicht ganze Log geschrieben wird.

Der Health-Check liest die. Ich habs 5ce403cec251926d6887a827eaa7861b460707e0 in ein Status-File umgebogen, dass nicht ganze Log geschrieben wird.
@ -24,0 +24,4 @@
####################################################################################################
echo "Running update once initially..."
sh /opt/update_camera.sh >> /var/log/update_camera_$(date +\%Y\%m\%d\%H\%M\%S).log 2>&1
Owner

s.o.

s.o.
Author
Collaborator
https://git.hamburg.ccc.de/CCCHH/sunders/pulls/24#issuecomment-8365
ViMaSter marked this conversation as resolved
@ -11,3 +12,3 @@
- mariadb:/var/lib/mysql
healthcheck:
test: ["CMD", "mariadb-admin", "ping", "-h", "localhost", "-uroot", "-prootpassword"]
test: ["CMD", "mariadb-admin", "ping", "-h", "localhost", "-uroot", "-prootpassword"] # ${{secrets.MYSQL_ROOT_PASSWORD}}
Owner

Warum das Passwort in einen Kommentar schreiben?

Warum das Passwort in einen Kommentar schreiben?
Author
Collaborator

Das Repo selbst hatte nichts nach Prod deployt. Jemand aus dem Infra Team hatte uns gebeten hier einfach nur zu kennzeichnen, wo welche Secrets hinsollten, weil das Compose-File quasi übernommen wurde und dann Secrets gesetzt wurden. Je nach dem wie wir jetzt deployen, kann das gern raus.

Das Repo selbst hatte nichts nach Prod deployt. Jemand aus dem Infra Team hatte uns gebeten hier einfach nur zu kennzeichnen, wo welche Secrets hinsollten, weil das Compose-File quasi übernommen wurde und dann Secrets gesetzt wurden. Je nach dem wie wir jetzt deployen, kann das gern raus.
Merge branch 'main' into healthcheck
All checks were successful
Build (and tag) Images / Build data_handler Image (push) Successful in 39s
Build (and tag) Images / Build web Image (push) Successful in 54s
6cd0d1ea4b
ViMaSter force-pushed healthcheck from 6cd0d1ea4b
All checks were successful
Build (and tag) Images / Build data_handler Image (push) Successful in 39s
Build (and tag) Images / Build web Image (push) Successful in 54s
to aa6ef7f362
All checks were successful
Build (and tag) Images / Build data_handler Image (push) Successful in 40s
Build (and tag) Images / Build web Image (push) Successful in 55s
2026-11-15 14:24:58 +01:00
Compare
fix: Send data handler output to container logs
All checks were successful
Build (and tag) Images / Build data_handler Image (push) Successful in 39s
Build (and tag) Images / Build web Image (push) Successful in 55s
5ce403cec2
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
stb approved these changes 2026-11-15 14:32:31 +01:00
stb merged commit f0ae09a7f5 into main 2026-11-15 14:32:36 +01:00
stb deleted branch healthcheck 2026-11-15 14:32:36 +01:00
Sign in to join this conversation.
No reviewers
stb
No labels
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
CCCHH/sunders!24
No description provided.