add delay option

This commit is contained in:
Karol Wypchlo 2021-01-21 12:29:31 +01:00
parent 7024b680e7
commit d695426f1d
1 changed files with 14 additions and 6 deletions

View File

@ -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