$ make instances
./scripts/instances.sh
CONTAINER                STATE                        INSTANCE       PID      REVISION
messenger-lab3-api-1     running/healthy              978f2777b379   95632    dev
messenger-lab3-api-2     running/healthy              389b271f592b   95685    dev
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080" 
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 129, "failed_attempts": 0, "first_recovery_seconds": 2.693}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
$ make instances
./scripts/instances.sh
CONTAINER                STATE                        INSTANCE       PID      REVISION
messenger-lab3-api-1     exited/unhealthy             -              0        dev
messenger-lab3-api-2     running/healthy              389b271f592b   95685    dev
$ docker inspect -f "{{.Name}} status={{.State.Status}} exit={{.State.ExitCode}} finished={{.State.FinishedAt}}" $(docker compose ps -aq api)
/messenger-lab3-api-1 status=exited exit=0 finished=2026-10-19T17:01:38.389851544Z
/messenger-lab3-api-2 status=running exit=0 finished=0001-01-01T00:00:00Z
$ docker compose logs api | grep -E "SIGTERM|Application stopped|Finished server process"
api-1  | 2026-10-19 17:01:37.194 | INFO     | __main__:shutdown:91 - SIGTERM: drain 1.0 с, instance=978f2777b379: порт закрыт, keep-alive соединения закрываются после ответа
api-1  | 2026-10-19 17:01:38.301 | INFO     | __main__:lifespan:54 - Application stopped, instance=978f2777b379, connections closed
api-1  | INFO:     Finished server process [1]
$ docker compose logs --no-log-prefix nginx | grep -E "\[(warn|error)\]" | tail -4
2026/10/19 17:00:46 [warn] 30#30: *43 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000001, client: 192.168.48.1, server: , request: "POST /api/v1/chats/01a1551b-c8fe-7b27-bef6-22c34e5e5367/messages HTTP/1.1", host: "localhost:8080"
2026/10/19 17:00:46 [warn] 30#30: *43 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000002, client: 192.168.48.1, server: , request: "POST /api/v1/chats/01a1551b-c8fe-7b27-bef6-22c34e5e5367/messages HTTP/1.1", host: "localhost:8080"
2026/10/19 17:01:38 [error] 30#30: *803 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.48.1, server: , request: "POST /api/v1/chats/01a1551c-8845-7e45-aa74-7d88537eac05/messages HTTP/1.1", upstream: "http://192.168.48.2:8080/api/v1/chats/01a1551c-8845-7e45-aa74-7d88537eac05/messages", host: "localhost:8080"
2026/10/19 17:01:38 [warn] 30#30: *803 upstream server temporarily disabled while connecting to upstream, client: 192.168.48.1, server: , request: "POST /api/v1/chats/01a1551c-8845-7e45-aa74-7d88537eac05/messages HTTP/1.1", upstream: "http://192.168.48.2:8080/api/v1/chats/01a1551c-8845-7e45-aa74-7d88537eac05/messages", host: "localhost:8080"
$ make restore
./scripts/restore.sh
 Container messenger-lab3-api-2  Running
 Container messenger-lab3-api-1  Starting
 Container messenger-lab3-api-1  Started
 Container messenger-lab3-api-1  Waiting
 Container messenger-lab3-api-2  Waiting
 Container messenger-lab3-api-1  Healthy
 Container messenger-lab3-api-2  Healthy
$ make instances
./scripts/instances.sh
CONTAINER                STATE                        INSTANCE       PID      REVISION
messenger-lab3-api-1     running/healthy              b0b074af6d9c   18674    dev
messenger-lab3-api-2     running/healthy              389b271f592b   95685    dev
