From a2b4e438f97b0fefa7213ffbc5e5bc8a67dc4277 Mon Sep 17 00:00:00 2001 From: sidey79 <7968127+sidey79@users.noreply.github.com> Date: Wed, 3 Apr 2024 20:42:21 +0200 Subject: [PATCH] Healthcheck timeout handling (#178) * Feat[healthcheck]: Added timeout to curl, to avoid blocking until docker kills the process * test[helathcheck]: Add some useful output if test fails --- src/health-check.sh | 2 ++ src/tests/bats/health-check.bats | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/health-check.sh b/src/health-check.sh index 970c133d..2dc5cd03 100755 --- a/src/health-check.sh +++ b/src/health-check.sh @@ -56,6 +56,8 @@ echo "$$" > $PID_FILE while IFS= read -r fhemUrl; do fhemwebState=$( curl \ + --connect-timeout 5 \ + --max-time 8 \ --silent \ --insecure \ --output /dev/null \ diff --git a/src/tests/bats/health-check.bats b/src/tests/bats/health-check.bats index 3e4e7e1f..dfeedd9e 100644 --- a/src/tests/bats/health-check.bats +++ b/src/tests/bats/health-check.bats @@ -63,6 +63,8 @@ teardown() { ((c++)) && ((c==50)) && echo "# fhem did not start" && break done sleep 5 + #cat $FHEM_CFG_FILE + cat ${LOG_FILE} assert_file_contains /tmp/health-check.urls "http://localhost:8083" run timeout 15 /health-check.sh