реализован уровень 4

This commit is contained in:
2026-10-15 20:12:22 +03:00
parent 158fed100c
commit 09b4b1d49d
25 changed files with 1794 additions and 91 deletions
+11
View File
@@ -0,0 +1,11 @@
#!/bin/sh
set -eu
project_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$project_root"
env_file=${ENV_FILE:-.env}
docker compose --env-file "$env_file" exec -T postgres sh -ec \
'exec psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB"' \
< tests/explain_history.sql
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
set -eu
project_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$project_root"
env_file=${ENV_FILE:-.env}
case "${DATABASE_ACTION:-}" in
stop)
docker compose --env-file "$env_file" stop postgres
;;
start)
docker compose --env-file "$env_file" up -d --wait postgres
;;
*)
echo "DATABASE_ACTION must be stop or start" >&2
exit 2
;;
esac
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
set -eu
project_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$project_root"
env_file=${ENV_FILE:-.env}
case "${CACHE_ACTION:-}" in
stop)
docker compose --env-file "$env_file" stop redis
;;
start)
docker compose --env-file "$env_file" up -d --wait redis
;;
*)
echo "CACHE_ACTION must be stop or start" >&2
exit 2
;;
esac
+4 -4
View File
@@ -7,9 +7,9 @@ cd "$project_root"
env_file=${ENV_FILE:-.env}
# PostgreSQL хранит все обязательные данные и сессии в named volume.
# Обычный restart не удаляет volume и не применяет миграции повторно.
docker compose --env-file "$env_file" restart postgres
docker compose --env-file "$env_file" up -d --wait postgres
# Redis содержит только восстанавливаемый кеш и намеренно не имеет volume.
docker compose --env-file "$env_file" restart postgres redis
docker compose --env-file "$env_file" up -d --wait postgres redis
# API перезапускается после восстановления готовности PostgreSQL.
# API перезапускается после восстановления обязательной БД и кеша.
docker compose --env-file "$env_file" restart api
+29
View File
@@ -0,0 +1,29 @@
#!/bin/sh
set -eu
project_root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$project_root"
env_file=${ENV_FILE:-.env}
case "${SESSION_TTL_ACTION:-}" in
short)
ttl=${SHORT_SESSION_TTL_SECONDS:-2}
case "$ttl" in
''|*[!0-9]*|0)
echo "SHORT_SESSION_TTL_SECONDS must be a positive integer" >&2
exit 2
;;
esac
SESSION_TTL_SECONDS="$ttl" docker compose --env-file "$env_file" \
up -d --no-deps --force-recreate --wait api
;;
restore)
docker compose --env-file "$env_file" \
up -d --no-deps --force-recreate --wait api
;;
*)
echo "SESSION_TTL_ACTION must be short or restore" >&2
exit 2
;;
esac