lab3 gusak

This commit is contained in:
2026-11-12 21:23:41 +03:00
parent 0ab3a341aa
commit 353ec4441d
36 changed files with 1706 additions and 32 deletions
+5
View File
@@ -0,0 +1,5 @@
#!/bin/sh
set -eu
# Restart API replicas and shared stores without removing named volumes.
docker compose --env-file .env restart api postgres redis lb
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh
set -eu
# Restart one API container at a time and wait for its healthcheck.
for container in $(docker compose --env-file .env ps -q api); do
docker restart "$container" >/dev/null
deadline=$(( $(date +%s) + 60 ))
while :; do
status=$(docker inspect --format '{{.State.Health.Status}}' "$container" 2>/dev/null || true)
[ "$status" = "healthy" ] && break
[ "$(date +%s)" -lt "$deadline" ] || exit 1
sleep 1
done
done
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh
set -eu
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}"
for container in $(docker compose --env-file .env ps -q api); do
hostname=$(docker inspect --format '{{.Config.Hostname}}' "$container")
if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then
docker stop "$container" >/dev/null
exit 0
fi
done
exit 2