This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
skynet-webportal/scripts/portal-down.sh

38 lines
810 B
Bash
Raw Normal View History

2020-09-04 12:55:30 +00:00
#!/bin/bash
set -e # exit on first error
while getopts d:t:r: flag
2021-01-21 11:29:31 +00:00
do
case "${flag}" in
d) delay=${OPTARG};;
t) timeout=${OPTARG};;
r) reason=${OPTARG};;
2021-01-21 11:29:31 +00:00
esac
done
delay=${delay:-0} # default to no delay
timeout=${timeout:-300} # default timeout is 300s
if [[ -z $reason ]]; then
echo "Please provide a reason for disabling the portal (use '-r <reason>')."
exit 1
fi
2020-09-04 12:55:30 +00:00
countdown() {
local secs=$1
while [ $secs -gt 0 ]; do
echo -ne "Waiting $secs\033[0K\r"
sleep 1
: $((secs--))
done
}
2021-01-21 11:29:31 +00:00
# delay disabling the portal
countdown $delay
# stop health-check so the server is taken our of load balancer
docker exec health-check cli disable $reason
2020-09-04 12:55:30 +00:00
# then wait 5 minutes for the load balancer to propagate the dns records
2021-01-21 11:29:31 +00:00
countdown $timeout