From 197c0089eec56ff8c2c107b88971fd80f9ee04ce Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Mon, 9 Jan 2023 16:51:19 +0100 Subject: [PATCH] Implemented excited check --- .../files/docker-health-check.sh | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/roles/native-docker-health-check/files/docker-health-check.sh b/roles/native-docker-health-check/files/docker-health-check.sh index 216f633c..ec0ca904 100644 --- a/roles/native-docker-health-check/files/docker-health-check.sh +++ b/roles/native-docker-health-check/files/docker-health-check.sh @@ -1,10 +1,20 @@ #!/bin/sh docker_ps_grep_unhealthy="$(docker ps | grep unhealthy)" -if [ -z "$docker_ps_grep_unhealthy" ] +docker_ps_grep_exited="$(docker ps -a | grep Exited)" +exitcode=0 +if [ ! -z "$docker_ps_grep_unhealthy" ] then - echo "All docker containers are healthy." - exit -else echo "Some docker containers are unhealthy: $docker_ps_grep_unhealthy" - exit 1 -fi \ No newline at end of file + exitcode=1 +fi +if [ ! -z "$docker_ps_grep_exited" ] +then + echo "Some docker containers exited: $docker_ps_grep_exited" + exitcode=2 +fi +if [ "$exitcode" -ne "0" ] +then + exit $exitcode +fi +echo "All docker containers are healthy." +exit \ No newline at end of file