lab3: LB + 2 API replicas, idempotency, X-Instance-Id, failover/persistence tests (grade 4)
This commit is contained in:
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
docker compose --env-file .env restart postgres cache api
|
||||
|
||||
i=0
|
||||
while [ $i -lt 60 ]; do
|
||||
if curl -sf http://localhost:8080/health/ready > /dev/null 2>&1; then
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
echo "stack did not become healthy in 60 seconds" >&2
|
||||
exit 1
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID environment variable is required}"
|
||||
|
||||
echo "Looking for API container with instance_id=$TARGET_INSTANCE_ID"
|
||||
|
||||
found=""
|
||||
for container in $(docker ps --format '{{.Names}}' | grep -E '^mtusi.*-api-[0-9]+$'); do
|
||||
if docker logs "$container" 2>&1 | grep -q "instance_id=$TARGET_INSTANCE_ID"; then
|
||||
found="$container"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$found" ]; then
|
||||
echo "ERROR: no container found with instance_id=$TARGET_INSTANCE_ID" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Stopping container: $found"
|
||||
docker stop "$found"
|
||||
|
||||
echo "Container $found stopped. Other replicas continue serving."
|
||||
exit 0
|
||||
Reference in New Issue
Block a user