Реализовать лабораторную 3 на оценку 5 (трек 1)
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
@echo off
|
||||
rem Restart API replicas, LB and state stores; named volumes are preserved.
|
||||
setlocal
|
||||
cd /d "%~dp0.."
|
||||
docker compose --env-file .env restart postgres redis api lb
|
||||
exit /b %ERRORLEVEL%
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
# Restart the API replicas, the load balancer and every state store while
|
||||
# keeping named volumes. Never run "down -v", flush Redis or re-seed data.
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
exec docker compose --env-file .env restart postgres redis api lb
|
||||
@@ -0,0 +1,19 @@
|
||||
@echo off
|
||||
rem Stop exactly ONE API replica identified by TARGET_INSTANCE_ID.
|
||||
rem The container hostname is the X-Instance-Id value used by the API.
|
||||
setlocal enabledelayedexpansion
|
||||
cd /d "%~dp0.."
|
||||
if "%TARGET_INSTANCE_ID%"=="" (
|
||||
echo TARGET_INSTANCE_ID is required 1>&2
|
||||
exit /b 2
|
||||
)
|
||||
for /f %%i in ('docker compose --env-file .env ps -q api') do (
|
||||
for /f %%h in ('docker inspect --format "{{.Config.Hostname}}" %%i') do (
|
||||
if "%%h"=="%TARGET_INSTANCE_ID%" (
|
||||
docker stop --time 1 %%i >nul
|
||||
exit /b 0
|
||||
)
|
||||
)
|
||||
)
|
||||
echo target API replica not found: %TARGET_INSTANCE_ID% 1>&2
|
||||
exit /b 1
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
# Stop exactly ONE API replica identified by the X-Instance-Id value supplied
|
||||
# in TARGET_INSTANCE_ID. The container hostname is the instance id, so the
|
||||
# mapping is deterministic and does not rely on container names.
|
||||
# Leave the replica stopped; restore it explicitly after the test.
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
target="${TARGET_INSTANCE_ID:?test provides target API instance alias}"
|
||||
|
||||
for id in $(docker compose --env-file .env ps -q api); do
|
||||
host=$(docker inspect --format '{{.Config.Hostname}}' "$id")
|
||||
if [ "$host" = "$target" ]; then
|
||||
docker stop --time 1 "$id" >/dev/null
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
printf '%s\n' "target API replica not found: $target" >&2
|
||||
exit 1
|
||||
Reference in New Issue
Block a user