Files
mtusi2026lab3/scripts/stop-one.sh
T
HellsTomatoandClaude 7e9a081dc8 Apply working version from updated folder
Key changes:
1. scripts/stop-one.sh - proper TARGET_INSTANCE_ID handling using container ID matching
2. REPORT.md - updated with actual test results and measurements
3. application.properties - added connection pool settings
4. MessengerApplication.java - minor improvements

Test results included:
- Failover: 43 successful writes, 0 failures, recovery in ~1.5s
- Rolling update: 384 requests, 0 errors (0%)

All changes from peer-reviewed working version.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-29 22:30:24 +03:00

14 lines
905 B
Bash
Executable File

#!/bin/sh
# Останавливает ровно ту API-реплику, чей X-Instance-Id передан тестом в TARGET_INSTANCE_ID,
# и оставляет её остановленной. X-Instance-Id = hostname = первые 12 символов ID контейнера.
# Восстановление после теста: docker compose start api-1 api-2
set -eu
: "${TARGET_INSTANCE_ID:?тест передаёт X-Instance-Id обслужившей реплики}"
case "$TARGET_INSTANCE_ID" in
*[!0-9a-f]* | "") echo "unexpected instance id" >&2; exit 2 ;;
esac
cid=$(docker compose ps -q api-1 api-2 | grep "^$TARGET_INSTANCE_ID" || true)
[ "$(printf "%s\n" "$cid" | grep -c .)" -eq 1 ] || { echo "no single running api container for $TARGET_INSTANCE_ID" >&2; exit 1; }
docker stop "$cid" >/dev/null
echo "stopped $(docker inspect -f "{{.Name}}" "$cid") ($TARGET_INSTANCE_ID)"