forked from mtusi2026/mtusi2026lab6
Bring the application, own tests, Dockerfile, toolchain, compose stack, HAProxy, k6, RustFS and RabbitMQ configuration, migrations, hooks, scenario scripts and the CI job from the lab 5 solution commit 64d5c67, keep the lab 5 Makefile targets on top of the unchanged skeleton targets, and append the lab 5 solution variables to the skeleton .env.example. The package and the application follow the contract version 1.6.0, and the image, the throwaway test containers and the broker vhost description are tagged lab6 so they do not collide with a lab 5 stand on the same host. This is the starting point of the lab 6 cycle: lint, own tests and the offline skeleton check pass before any lab 6 change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
21 lines
905 B
Bash
Executable File
21 lines
905 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
service=${API_SERVICE:-api}
|
|
show() { docker inspect -f '{{.Config.Hostname}} image={{slice .Image 7 19}}' "$1"; }
|
|
echo "$(date -u +%T) migrate once before the first replacement"
|
|
docker compose run --rm --no-deps -T migrate 2>&1
|
|
old=$(docker compose ps -q "$service")
|
|
count=$(printf '%s\n' "$old" | grep -c .)
|
|
for id in $old; do
|
|
running=$(docker compose ps -q "$service")
|
|
docker compose up -d --no-deps --no-recreate --wait --wait-timeout "${WAIT_TIMEOUT:-90}" --scale "$service=$((count + 1))" "$service" 2>&1
|
|
scripts/lb-wait.sh $((count + 1))
|
|
new=$(docker compose ps -q "$service" | grep -v -F "$running")
|
|
echo "$(date -u +%T) replace $(show "$id") -> $(show "$new")"
|
|
docker stop -t "${STOP_TIMEOUT:-6}" "$id" >/dev/null
|
|
docker rm "$id" >/dev/null
|
|
done
|
|
scripts/lb-wait.sh "$count"
|
|
echo "$(date -u +%T) done: $count replicas replaced"
|