Files
mtusi2026lab2-fork/scripts/restart.sh
2026-10-01 16:53:27 +03:00

26 lines
721 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
set -eu
# Перезапускает API и все хранилища (postgres, redis), сохраняя volumes.
# Никаких down -v / flush / reseed.
COMPOSE="docker compose --env-file .env"
$COMPOSE stop api
$COMPOSE restart postgres
$COMPOSE restart redis
# Ждём healthy у postgres и redis.
for i in $(seq 1 60); do
pg_ok=$($COMPOSE ps --format json postgres | grep -c '"Health":"healthy"' || true)
rd_ok=$($COMPOSE ps --format json redis | grep -c '"Health":"healthy"' || true)
if [ "$pg_ok" -ge 1 ] && [ "$rd_ok" -ge 1 ]; then
break
fi
sleep 1
done
$COMPOSE up -d api
# Готовность API проверит сам тест; здесь возвращаем 0.
exit 0