код из lab3

This commit is contained in:
2026-10-28 14:12:41 +03:00
parent ec540a1a72
commit 14166003b8
49 changed files with 5174 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
set -eu
N=2
export APP_VERSION="${APP_VERSION:-v$(date +%s)}"
wait_healthy() {
until [ "$(docker compose ps -q api | xargs docker inspect -f '{{.State.Health.Status}}' | grep -c '^healthy$')" = "$1" ]; do sleep 1; done
}
docker compose build api
for old in $(docker compose ps -q api); do
docker compose up -d --no-deps --no-recreate --scale api=$((N+1)) api
wait_healthy $((N+1))
sleep 5 # LB: rise 2 + обновление DNS
echo "$(date +%T) replacing $(docker inspect -f '{{.Name}}' "$old")"
docker stop -t 20 "$old" >/dev/null
docker rm "$old" >/dev/null
done
wait_healthy $N
echo "$(date +%T) done, APP_VERSION=$APP_VERSION"