add safe stop and restart sia scripts

This commit is contained in:
Karol Wypchlo 2020-09-04 14:55:30 +02:00
parent aa2dff5e5f
commit 2c12b9d009
3 changed files with 50 additions and 8 deletions

View File

@ -90,16 +90,23 @@ At this point we have almost everything running, we just need to set up your wal
## Useful Commands ## Useful Commands
- Starting the whole stack
> `docker-compose up -d`
- Stopping the whole stack
> `docker-compose down`
- Accessing siac - Accessing siac
> `docker exec -it sia siac` > `docker exec -it sia siac`
- Checking status of siad service - Stopping sia service
> `systemctl --user status siad` - safe method - stops health-check service and wait for dns propagation
- Stopping siad service > `setup-scripts/sia-stop.sh`
> `systemctl --user stop siad` - unsafe (force stop)
- Starting siad service > `docker-compose down sia`
> `systemctl --user start siad` - Restarting sia service
- Restarting siad service - safe method - stops health-check service and wait for dns propagation
> `systemctl --user restart siad` > `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 - Restarting caddy gracefully after making changes to Caddyfile
> `docker exec caddy caddy reload --config /etc/caddy/Caddyfile` > `docker exec caddy caddy reload --config /etc/caddy/Caddyfile`
- Restarting nginx gracefully after making changes to nginx configs - Restarting nginx gracefully after making changes to nginx configs

14
setup-scripts/sia-restart.sh Executable file
View File

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

21
setup-scripts/sia-stop.sh Executable file
View File

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