Files
mtusi2026lab4/scripts/restart.sh
T
2026-11-06 18:05:29 +03:00

24 lines
740 B
Bash

#!/bin/sh
# Restart API and every state store without deleting volumes.
#
# Used by make test-persistence. Sessions live in Valkey with AOF and users,
# chats and messages in PostgreSQL, so the same bearer token and data survive.
set -eu
stack=${STACK_NAME:-lab4}
for service in "${stack}_postgres" "${stack}_valkey" "${stack}_minio" "${stack}_api" "${stack}_traefik"; do
printf 'restarting %s\n' "$service"
docker service update --force "$service" >/dev/null
done
i=0
while [ "$i" -lt 60 ]; do
if curl -fsS http://127.0.0.1:8080/health/ready >/dev/null 2>&1; then
printf 'stack ready after restart\n'
exit 0
fi
i=$((i + 1))
sleep 2
done
printf 'stack did not become ready within 120s\n' >&2
exit 1