ЛР 5 — асинхронная обработка и версии pipeline

This commit is contained in:
2026-11-16 02:38:13 +03:00
parent 276dbdad8a
commit 1f535f1b5b
163 changed files with 17194 additions and 24 deletions
+43
View File
@@ -0,0 +1,43 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
if [ -f .env ]; then
compose() { docker compose --env-file .env "$@"; }
else
: "${COMPOSE_PROJECT_NAME:?COMPOSE_PROJECT_NAME is required when .env is absent}"
compose() { docker compose "$@"; }
fi
wait_healthy() {
for service in "$@"; do
containers=$(compose ps -q "$service")
[ -n "$containers" ] || { echo "$service has no running containers" >&2; return 1; }
for container in $containers; do
attempts=0
until [ "$(docker inspect --format '{{.State.Health.Status}}' "$container")" = healthy ]; do
attempts=$((attempts + 1))
[ "$attempts" -lt 30 ] || { echo "$service did not become healthy" >&2; return 1; }
sleep 1
done
done
done
}
restart_services() {
for service in "$@"; do
containers=$(compose ps -a -q "$service")
[ -n "$containers" ] || { echo "$service has no containers" >&2; return 1; }
docker restart --timeout 20 $containers >/dev/null
done
}
# Restart only long-running services and preserve their containers and volumes.
compose stop worker relay attachment-cleanup >/dev/null
restart_services postgres redis s3 rabbitmq
wait_healthy postgres redis s3 rabbitmq
restart_services api
wait_healthy api
restart_services lb
restart_services relay worker attachment-cleanup