From 77c1cf22a681256a16d5040822ce81aa8e08cd00 Mon Sep 17 00:00:00 2001 From: gsd Date: Wed, 16 Oct 2024 14:05:30 +0300 Subject: [PATCH] check fix --- upcheck.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/upcheck.sh b/upcheck.sh index a80f236..9f92aa9 100755 --- a/upcheck.sh +++ b/upcheck.sh @@ -11,12 +11,22 @@ if [ "$CHECK_CONTAINER" == "0" ]; then exit 0 fi -RESULT="$(docker exec -it $CONTAINER ping -c 1 -W 1 $PINGHOST > /dev/null && echo 'pass' || echo 'fail')" -#echo $RESULT +COUNT=0 +MAXPING=30 -if [ "$RESULT" != "pass" ]; then - echo 'container is not good' - docker compose down - docker compose up -d - exit 0 -fi +while [ $COUNT -le $MAXPING ] +do + COUNT=`expr $COUNT + 1` + RESULT="$(docker exec -it $CONTAINER ping -c 1 -W 1 $PINGHOST > /dev/null && echo 'pass' || echo 'fail')" + + if [ "$RESULT" == "pass" ]; then + exit 0 + fi + + if [ $COUNT -ge 29 ]; then + echo 'container is not good' + docker compose down + docker compose up -d + exit 0 + fi +done