ЛР 2: PostgreSQL, сессии в Valkey, трек 2

This commit is contained in:
alenchha
2026-10-19 19:11:28 +03:00
parent 65003b6119
commit 6bec450e20
50 changed files with 3210 additions and 14 deletions
+35
View File
@@ -0,0 +1,35 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
NAME=mtusi-lab2-api-shortttl
PORT=${PORT:-8081}
NETWORK=$(docker compose --env-file .env ps --format '{{.Name}}' api | head -1 | xargs -I{} docker inspect {} --format '{{range $k,$v := .NetworkSettings.Networks}}{{$k}}{{end}}')
cleanup() {
docker rm -f "$NAME" >/dev/null 2>&1 || true
}
trap cleanup EXIT
cleanup
echo "Поднимаю отдельный API с SESSION_TTL_SECONDS=2 на порту $PORT (сеть $NETWORK)"
docker run -d --name "$NAME" --network "$NETWORK" \
-p 127.0.0.1:"$PORT":8080 \
-v "$PWD/secrets/database_url:/run/secrets/database_url:ro" \
-v "$PWD/secrets/cache_url:/run/secrets/cache_url:ro" \
-e DATABASE_URL_FILE=/run/secrets/database_url \
-e CACHE_URL_FILE=/run/secrets/cache_url \
-e SESSION_TTL_SECONDS=2 \
-e SESSION_CACHE_TTL_SECONDS=2 \
-e SESSION_SWEEP_SECONDS=5 \
mtusi-messenger:lab2 >/dev/null
i=0
while [ "$i" -lt 60 ]; do
if curl -fsS "http://localhost:$PORT/health/ready" >/dev/null 2>&1; then break; fi
i=$((i + 1))
sleep 1
done
curl -fsS "http://localhost:$PORT/health/ready" >/dev/null
python3 student-tests/test_expiry.py --base-url "http://localhost:$PORT"