Files
mtusi2026lab3/scripts/restart.sh
T
2026-10-13 19:11:11 +03:00

20 lines
914 B
Bash

#!/bin/sh
# Persistence hook: restarts the LB, every API replica and both stores
# (PostgreSQL with its volume, 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)
[ -n "$api" ] && [ -n "$db" ] && [ -n "$lb" ] && [ -n "$valkey" ] || { echo "stack is not running" >&2; exit 2; }
echo "stopping lb + api, then db + valkey"
docker stop --time 15 $lb $api >/dev/null
docker stop --time 30 $db $valkey >/dev/null
echo "starting db + valkey"
docker start $db $valkey >/dev/null
wait_healthy 60 $db $valkey
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) api=$(for i in $api; do short $i; done | tr '\n' ' ')"