Implement lab2 PostgreSQL authentication and Redis sessions

This commit is contained in:
ferraronp
2026-10-23 18:33:06 +03:00
parent 65003b6119
commit 5dd32a77ac
23 changed files with 1126 additions and 55 deletions
+37
View File
@@ -0,0 +1,37 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
compose() {
docker compose --env-file .env "$@"
}
printf '%s\n' '[restart] Stopping API...'
compose stop api
printf '%s\n' '[restart] Stopping Redis...'
compose stop redis
printf '%s\n' '[restart] Stopping PostgreSQL...'
compose stop postgres
printf '%s\n' '[restart] Starting PostgreSQL and Redis; waiting for healthchecks...'
compose up -d --no-deps --wait --wait-timeout 60 postgres redis
printf '%s\n' '[restart] Starting API...'
compose up -d --no-deps api
printf '%s\n' '[restart] Waiting for API readiness...'
i=0
while [ "$i" -lt 60 ]; do
if compose exec -T api python -c 'import urllib.request; urllib.request.urlopen("http://127.0.0.1:8080/health/ready", timeout=2)' >/dev/null 2>&1; then
printf '%s\n' '[restart] OK: all runtime services restarted; API ready.'
exit 0
fi
i=$((i + 1))
sleep 1
done
printf '%s\n' '[restart] FAILED: API did not become ready within 60 seconds; inspect docker compose ps/logs.' >&2
exit 1