Реализовать лабораторную 4 на оценку 5

Добавить приватное S3-хранилище, вложения, presigned upload, reconciler и доказательства.
This commit is contained in:
Чиняева
2026-11-07 01:37:21 +03:00
parent ec540a1a72
commit f39ae06ef3
69 changed files with 5254 additions and 31 deletions
+42
View File
@@ -0,0 +1,42 @@
#!/bin/sh
# Stop exactly ONE API replica identified by the public X-Instance-Id alias.
# The public failover test sets TARGET_INSTANCE_ID and expects this script to
# return within 10 seconds while leaving the replica stopped. It never touches
# PostgreSQL, Redis, the LB or named volumes.
set -eu
: "${TARGET_INSTANCE_ID:?test provides the target API instance alias}"
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$ROOT"
ENV_FILE=${ENV_FILE:-.env}
COMPOSE="docker compose --env-file $ENV_FILE"
target=$TARGET_INSTANCE_ID
found=''
for id in $($COMPOSE ps -q api); do
host=$(docker inspect --format '{{.Config.Hostname}}' "$id")
name=$(docker inspect --format '{{.Name}}' "$id")
case "$host" in
"$target"|"$target"*) found=$id; break ;;
esac
case "$target" in
"$host"|"$host"*) found=$id; break ;;
esac
# INSTANCE_ID may be set explicitly by an operator; then it is not the
# container hostname and the default mapping cannot be used.
if [ "$host" != "$name" ] && [ "${name#/}" = "$target" ]; then
found=$id
break
fi
done
if [ -z "$found" ]; then
echo "stop-one: no API replica matches TARGET_INSTANCE_ID" >&2
exit 3
fi
# -t 5 bounds the graceful drain; gunicorn exits earlier when idle. Docker
# does not restart a container stopped explicitly, even with restart policy.
docker stop --time 5 "$found" >/dev/null
exit 0