From d695426f1d9b64b9539bd67e58c097fcc147e744 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Thu, 21 Jan 2021 12:29:31 +0100 Subject: [PATCH] add delay option --- scripts/portal-down.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/portal-down.sh b/scripts/portal-down.sh index 3b1e9a94..0b42b53a 100755 --- a/scripts/portal-down.sh +++ b/scripts/portal-down.sh @@ -2,10 +2,15 @@ set -e # exit on first error -TIMEOUT=${1:-300} # default timeout is 300s -if ! [[ "$TIMEOUT" =~ ^[0-9]+$ ]]; then - echo "Timeout has to be valid integer" && exit 1 -fi +while getopts d:t: flag +do + case "${flag}" in + d) delay=${OPTARG};; + t) timeout=${OPTARG};; + esac +done +delay=${delay:-0} # default to no delay +timeout=${timeout:-300} # default timeout is 300s countdown() { local secs=$1 @@ -16,8 +21,11 @@ countdown() { done } +# delay disabling the portal +countdown $delay + # stop healh-check so the server is taken our of load balancer -# docker exec health-check cli/disable +docker exec health-check cli/disable # then wait 5 minutes for the load balancer to propagate the dns records -countdown $TIMEOUT +countdown $timeout