From 9267555837e6d25790b6d0679b5f80edcb854ccd Mon Sep 17 00:00:00 2001
From: Sotiris Tsepelakis <sotirios.tsepelakis@tuwien.ac.at>
Date: Tue, 15 Oct 2024 12:47:53 +0200
Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=BA=20Keycloak:=20modify=20healthcheck?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Starting from v25, healthchecks are exposed at port 9000
---
 scripts/kc-healthcheck.sh | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/scripts/kc-healthcheck.sh b/scripts/kc-healthcheck.sh
index 963c631..bb6d72d 100755
--- a/scripts/kc-healthcheck.sh
+++ b/scripts/kc-healthcheck.sh
@@ -3,14 +3,14 @@
 # Healthcheck script for Keycloak. Starting from v21, Keycloak doesn't include curl anymore,
 # thus we use a custom health check.
 
-exec 3<>/dev/tcp/localhost/8080
+exec 3<>/dev/tcp/localhost/9000
 
-echo -e "GET /auth/health/ready HTTP/1.1\nhost: localhost:8080\n" >&3
+echo -e 'GET /health/ready HTTP/1.1\r\nhost: http://localhost\r\nConnection: close\r\n\r\n' >&3
 
-timeout --preserve-status 1 cat <&3 | grep -m 1 status | grep -m 1 UP
-STATUS=$?
-
-exec 3<&-
-exec 3>&-
-
-exit $STATUS
+if [ $? -eq 0 ]; then
+    echo 'Healthcheck Successful'
+    exit 0
+else
+    echo 'Healthcheck Failed'
+    exit 1
+fi
-- 
GitLab