ЛР 3: балансировка, 2 реплики API и общая идемпотентность (оценка 3)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
@echo off
|
||||
REM Windows equivalent of scripts/restart.sh for the local persistence hook.
|
||||
cd /d "%~dp0.."
|
||||
docker compose --env-file .env restart db api1 api2
|
||||
exit /b %ERRORLEVEL%
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
# Explicit persistence hook for lab3.
|
||||
# Restart both API replicas and PostgreSQL. Volumes are preserved: no down -v,
|
||||
# no flush, no re-seed. The load balancer stays in front of the replicas.
|
||||
cd "$(dirname "$0")/.."
|
||||
docker compose restart db api1 api2
|
||||
@@ -0,0 +1,10 @@
|
||||
@echo off
|
||||
REM Windows equivalent of scripts/stop-one.sh for the local failover hook.
|
||||
cd /d "%~dp0.."
|
||||
if "%TARGET_INSTANCE_ID%"=="api1" goto stop
|
||||
if "%TARGET_INSTANCE_ID%"=="api2" goto stop
|
||||
echo unknown target instance: %TARGET_INSTANCE_ID% >&2
|
||||
exit /b 1
|
||||
:stop
|
||||
docker compose --env-file .env stop %TARGET_INSTANCE_ID%
|
||||
exit /b %ERRORLEVEL%
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
# Explicit failover hook: stop exactly ONE API replica selected by the test.
|
||||
# TARGET_INSTANCE_ID is the X-Instance-Id served by that replica (api1 or api2).
|
||||
# DB, volume and load balancer are untouched. Return quickly; leave the replica stopped.
|
||||
cd "$(dirname "$0")/.."
|
||||
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
|
||||
case "$TARGET_INSTANCE_ID" in
|
||||
api1|api2) docker compose stop "$TARGET_INSTANCE_ID" ;;
|
||||
*) echo "unknown target instance: $TARGET_INSTANCE_ID" >&2; exit 1 ;;
|
||||
esac
|
||||
Reference in New Issue
Block a user