Files
mtusi2026lab3/scripts/stop-one.sh
T
HellsTomatoandClaude 508d512438 Fix lab3 issues for grade 4
Fixes for mandatory level 3:
1. Reduce nginx proxy_connect_timeout to 1s for faster failover detection
   - Prevents 499 errors during failover (client timeout < connect timeout)
2. Set executable permissions on scripts (git update-index --chmod=+x)
   - restart.sh, stop-one.sh now 100755
3. Fix REPORT.md errors:
   - Correct test command: make test-failover (not py -3 tests\failover.py)
   - Fix health check explanation (nginx uses timeouts, not Docker healthcheck)
   - Fix line numbers: INSTANCE_ID=39, X-Instance-Id=88, message()=321
   - Add note about nginx warmup period (~10s after startup)

Additions for level 4:
4. Add scripts/measure-failover.sh - measure RPS, errors, recovery time
   - Sequential testing of api-1 and api-2 stops
   - Baseline, failover, and recovery measurements
5. Add scripts/rolling-update.sh - demonstrate rolling update under load
   - Generates load for 60s while updating replicas sequentially
   - Measures errors during rolling update
6. Update REPORT.md with sections 10-11 for level 4 requirements

All changes address reviewer feedback and ensure tests pass consistently.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-29 21:02:00 +03:00

19 lines
862 B
Bash
Executable File

#!/bin/bash
# Скрипт остановки одной API-реплики для демонстрации failover.
set -e
# Имя сервиса для остановки (по умолчанию api-1).
TARGET_INSTANCE_ID="${1:-api-1}"
echo "Останавливаем контейнер $TARGET_INSTANCE_ID..."
docker compose stop "$TARGET_INSTANCE_ID"
echo "Проверяем, что контейнер действительно остановлен..."
docker compose ps "$TARGET_INSTANCE_ID"
echo "Контейнер $TARGET_INSTANCE_ID остановлен. Другая реплика продолжает работу."
echo "Проверяем доступность API через балансировщик..."
sleep 2
curl -f http://localhost:8080/health/ready && echo "API доступен через оставшуюся реплику"