forked from mtusi2026/mtusi2026lab2
реализован уровень 4
This commit is contained in:
Executable
+11
@@ -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
|
||||
Executable
+20
@@ -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
|
||||
Executable
+20
@@ -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
@@ -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
|
||||
|
||||
Executable
+29
@@ -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
|
||||
Reference in New Issue
Block a user