Files
mtusi2026lab7/scripts/restart.sh
T

31 lines
1.4 KiB
Bash
Raw 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
# lab7: перезапуск LB, обеих реплик API, PostgreSQL, Redis, MinIO, OpenBao
# и s3_cleanup. Volumes сохраняются. После рестарта OpenBao sealed —
# его надо распечатать (unseal), что делает openbao-init (идемпотентно).
# 1) openbao после рестарта sealed — unseal через openbao-init.
# openbao-init зависит от openbao (healthy) и security_init (completed).
docker compose --env-file .env up -d openbao >/dev/null 2>&1 || true
docker compose --env-file .env run --rm --no-deps openbao-init >/dev/null 2>&1 || true
# 2) Перезапуск остальных сервисов (volumes сохраняются).
docker compose --env-file .env restart lb api postgres redis minio s3_cleanup >/dev/null 2>&1 || {
docker restart mtuci-lb >/dev/null 2>&1 || true
docker restart mtuci-postgres >/dev/null 2>&1 || true
docker restart mtuci-redis >/dev/null 2>&1 || true
docker restart mtuci-minio >/dev/null 2>&1 || true
for c in $(docker ps -a --filter "name=mtuci2026lab7_api" -q); do
docker restart "$c" >/dev/null 2>&1 || true
done
}
# 3) Ждём готовности LB :8443 по HTTPS с проверкой CA.
i=0
while [ $i -lt 90 ]; do
if curl -fsS --cacert ./certs/ca.crt https://localhost:8443/health/ready >/dev/null 2>&1; then
exit 0
fi
i=$((i+1)); sleep 1
done
exit 1