From a4d68ce8829b0b0fefec1e4eeb91818f9e1585c2 Mon Sep 17 00:00:00 2001 From: Arvinth C Date: Tue, 21 Nov 2023 11:18:51 +0530 Subject: [PATCH] Adding health check for backup gateway Signed-off-by: Arvinth C --- .../backup-gateway/habitat/hooks/health-check | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 components/backup-gateway/habitat/hooks/health-check diff --git a/components/backup-gateway/habitat/hooks/health-check b/components/backup-gateway/habitat/hooks/health-check new file mode 100644 index 00000000000..a203b69f7d9 --- /dev/null +++ b/components/backup-gateway/habitat/hooks/health-check @@ -0,0 +1,20 @@ +#!{{pkgPathFor "core/bash"}}/bin/bash + +exec 2>&1 + +curlOpts="-sS --fail --max-time 2" +curlOpts="$curlOpts --cert {{pkg.svc_config_path}}/public.crt" +curlOpts="$curlOpts --key {{pkg.svc_config_path}}/private.key" +curlOpts="$curlOpts --cacert /hab/svc/automate-gateway/config/root_ca.crt" +curlOpts="$curlOpts --resolve backup-gateway:{{cfg.service.port}}:127.0.0.1" +curlOpts="$curlOpts --noproxy backup-gateway" + +# shellcheck disable=SC2086 +output=$(curl $curlOpts https://backup-gateway:{{cfg.service.port}}/minio/health/ready 2>&1) +res=$? +echo "$output" +if [[ "$res" != "0" ]]; then + echo "health check curl command returned exit code $res:" + echo "$output" + exit 2 +fi