Files
mtusi2026lab4/scripts/restart.sh
T
2026-10-30 16:53:49 +03:00

21 lines
998 B
Bash

#!/bin/sh
# Persistence hook: restarts the LB, every API replica and all stores
# (PostgreSQL and S3 with their volumes, Valkey cache). No "down -v", no re-seed.
# Uses only the docker CLI and Compose labels, so it also runs in "tester".
set -eu
. "$(dirname "$0")/lib.sh"
api=$(service_ids api); lb=$(service_ids lb); db=$(service_ids db)
valkey=$(service_ids valkey); s3=$(service_ids s3)
[ -n "$api" ] && [ -n "$db" ] && [ -n "$lb" ] && [ -n "$valkey" ] && [ -n "$s3" ] || { echo "stack is not running" >&2; exit 2; }
echo "stopping lb + api, then db + valkey + s3"
docker stop --time 15 $lb $api >/dev/null
docker stop --time 30 $db $valkey $s3 >/dev/null
echo "starting db + valkey + s3"
docker start $db $valkey $s3 >/dev/null
wait_healthy 80 $db $valkey $s3
echo "starting api"
docker start $api >/dev/null
wait_healthy 60 $api
docker start $lb >/dev/null
echo "restart complete: db=$(short $db) valkey=$(short $valkey) s3=$(short $s3) api=$(for i in $api; do short $i; done | tr '\n' ' ')"