forked from mtusi2026/mtusi2026lab7
solution
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
compose() {
|
||||
docker compose --env-file .env "$@"
|
||||
}
|
||||
|
||||
wait_healthy() {
|
||||
for service in "$@"; do
|
||||
attempts=0
|
||||
until states=$(compose ps --format '{{.Health}}' "$service") \
|
||||
&& [ -n "$states" ] \
|
||||
&& [ -z "$(printf '%s\n' "$states" | grep -v '^healthy$')" ]; do
|
||||
attempts=$((attempts + 1))
|
||||
if [ "$attempts" -ge 60 ]; then
|
||||
echo "$service не стал healthy за 60 секунд" >&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
worker_running=$(compose ps --status running --quiet worker)
|
||||
compose stop worker publisher cleanup
|
||||
compose restart postgres redis minio broker prometheus loki tempo grafana otel-collector
|
||||
wait_healthy postgres redis minio broker
|
||||
compose restart openbao
|
||||
"${PYTHON:-python3}" -m scripts.bootstrap_bao --unseal-only --port "${BAO_HOST_PORT:-18200}"
|
||||
wait_healthy openbao
|
||||
compose restart api nginx
|
||||
wait_healthy api nginx
|
||||
# Compose start также запускает завершённые migrate/bootstrap dependencies.
|
||||
# Здесь нужны только ранее созданные фоновые контейнеры, без повторного bootstrap.
|
||||
background_ids=$(compose ps --all --quiet publisher cleanup)
|
||||
docker start $background_ids
|
||||
# Сценарий с заранее остановленным worker сохраняет его остановленным.
|
||||
if [ -n "$worker_running" ]; then
|
||||
worker_ids=$(compose ps --all --quiet worker)
|
||||
docker start $worker_ids
|
||||
fi
|
||||
# Пока восстанавливался бизнес-путь, telemetry backend тоже успели запуститься.
|
||||
# Grafana healthcheck проверяет также готовность Loki, Tempo и Collector.
|
||||
wait_healthy grafana
|
||||
Reference in New Issue
Block a user