From ba7cb64d34286ad7f754161dba45151ae9040a1d Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Thu, 21 Jan 2021 12:04:21 +0100 Subject: [PATCH 1/3] update portal scripts --- scripts/portal-restart.sh | 18 ++++++++++++++++++ scripts/portal-upgrade.sh | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 scripts/portal-restart.sh diff --git a/scripts/portal-restart.sh b/scripts/portal-restart.sh new file mode 100644 index 00000000..354bfdbf --- /dev/null +++ b/scripts/portal-restart.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e # exit on first error + +# get current working directory (pwd doesn't cut it) +cwd=$(cd -P -- "$(dirname -- "$0")" && pwd -P) + +# put the server down for maintenance +. ${cwd}/portal-down.sh + +# stop the docker services +docker-compose down + +# start the docker services +docker-compose up -d + +# enable the server again +. ${cwd}/portal-up.sh diff --git a/scripts/portal-upgrade.sh b/scripts/portal-upgrade.sh index f63335bc..da863bca 100755 --- a/scripts/portal-upgrade.sh +++ b/scripts/portal-upgrade.sh @@ -21,7 +21,7 @@ docker system prune --force docker volume rm $(docker volume ls -q) # build all container without cache -docker-compose build --no-cache +docker-compose build --no-cache --parallel --pull --quiet # start the docker services docker-compose up -d From 7024b680e785ae04cd795ca4d5adb3741a17dfcc Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Thu, 21 Jan 2021 12:15:10 +0100 Subject: [PATCH 2/3] add timeout option to portal-down script --- scripts/portal-down.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/portal-down.sh b/scripts/portal-down.sh index b2a9593c..3b1e9a94 100755 --- a/scripts/portal-down.sh +++ b/scripts/portal-down.sh @@ -2,6 +2,11 @@ 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 + countdown() { local secs=$1 while [ $secs -gt 0 ]; do @@ -12,7 +17,7 @@ countdown() { } # 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 300 +countdown $TIMEOUT From d695426f1d9b64b9539bd67e58c097fcc147e744 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Thu, 21 Jan 2021 12:29:31 +0100 Subject: [PATCH 3/3] 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