From 2c12b9d00969447aa1a1239c8f5d6374a60a6850 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Fri, 4 Sep 2020 14:55:30 +0200 Subject: [PATCH] add safe stop and restart sia scripts --- setup-scripts/README.md | 23 +++++++++++++++-------- setup-scripts/sia-restart.sh | 14 ++++++++++++++ setup-scripts/sia-stop.sh | 21 +++++++++++++++++++++ 3 files changed, 50 insertions(+), 8 deletions(-) create mode 100755 setup-scripts/sia-restart.sh create mode 100755 setup-scripts/sia-stop.sh diff --git a/setup-scripts/README.md b/setup-scripts/README.md index 9083dae7..ea8aeba9 100644 --- a/setup-scripts/README.md +++ b/setup-scripts/README.md @@ -90,16 +90,23 @@ At this point we have almost everything running, we just need to set up your wal ## Useful Commands +- Starting the whole stack + > `docker-compose up -d` +- Stopping the whole stack + > `docker-compose down` - Accessing siac > `docker exec -it sia siac` -- Checking status of siad service - > `systemctl --user status siad` -- Stopping siad service - > `systemctl --user stop siad` -- Starting siad service - > `systemctl --user start siad` -- Restarting siad service - > `systemctl --user restart siad` +- Stopping sia service + - safe method - stops health-check service and wait for dns propagation + > `setup-scripts/sia-stop.sh` + - unsafe (force stop) + > `docker-compose down sia` +- Restarting sia service + - safe method - stops health-check service and wait for dns propagation + > `setup-scripts/sia-restart.sh` + - unsafe (force restart) + > `docker-compose down sia` + > `docker compose up -d sia` - Restarting caddy gracefully after making changes to Caddyfile > `docker exec caddy caddy reload --config /etc/caddy/Caddyfile` - Restarting nginx gracefully after making changes to nginx configs diff --git a/setup-scripts/sia-restart.sh b/setup-scripts/sia-restart.sh new file mode 100755 index 00000000..7316444b --- /dev/null +++ b/setup-scripts/sia-restart.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e # exit on first error + +cwd + +# get current working directory (pwd doesn't cut it) +cwd=$(cd -P -- "$(dirname -- "$0")" && pwd -P) + +# run the sia-stop script +. ${cwd}/sia-stop.sh + +# start sia +docker-compose up -d sia \ No newline at end of file diff --git a/setup-scripts/sia-stop.sh b/setup-scripts/sia-stop.sh new file mode 100755 index 00000000..64dce4dd --- /dev/null +++ b/setup-scripts/sia-stop.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -e # exit on first error + +countdown() { + local secs=$1 + while [ $secs -gt 0 ]; do + echo -ne "Waiting $secs\033[0K\r" + sleep 1 + : $((secs--)) + done +} + +# first stop healh-check so the server is taken our of load balancer +docker-compose stop health-check + +# then wait 5 minutes for the load balancer to propagate the dns records +countdown 300 + +# now stop sia process +docker-compose stop sia \ No newline at end of file