40 lines
1.1 KiB
Bash
40 lines
1.1 KiB
Bash
#!/bin/sh
|
|
# Restart the API and every state store it depends on, keeping schema and data.
|
|
#
|
|
# Published as the action script for `make test-persistence`: it must not remove
|
|
# volumes, must not flush state and must not re-seed anything. Sessions live in
|
|
# Valkey with AOF, so the same token keeps working after the restart.
|
|
# Usage: sh scripts/restart.sh
|
|
set -eu
|
|
|
|
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
cd "$root"
|
|
|
|
if ! docker compose version >/dev/null 2>&1; then
|
|
printf 'docker compose is required\n' >&2
|
|
exit 2
|
|
fi
|
|
|
|
printf '=== services before restart ===\n'
|
|
docker compose ps
|
|
|
|
printf '=== restart api postgres valkey (grace 10s) ===\n'
|
|
docker compose restart --timeout 10 api postgres valkey
|
|
|
|
printf '=== services after restart ===\n'
|
|
docker compose ps
|
|
|
|
running=$(docker compose ps --status running --services | sort | tr '\n' ' ')
|
|
printf 'running services: %s\n' "$running"
|
|
for service in api postgres valkey; do
|
|
case " $running " in
|
|
*" $service "*) ;;
|
|
*)
|
|
printf 'service %s is not running\n' "$service" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
printf 'restart complete\n'
|