Durable staging handoff, transactional outbox, at-least-once worker with lease fencing, idempotent versioned pipeline, three variants, operator tooling, contract tests and evidence. Includes the review fixes: reprocess source selection and failure settlement, replay guards, stale-job retirement, PNG structural/raster validation, migration rollback safety and audit events.
59 lines
2.0 KiB
Bash
Executable File
59 lines
2.0 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
# Restart hook: bounce API replicas, worker/relay and every state store of the lab5 stand.
|
|
#
|
|
# scripts/restart.sh
|
|
#
|
|
# Persistent volumes are kept: no `down -v`, no flush, no re-seed. The one-shot
|
|
# `migrate` service is not re-run (schema stays as it is, data and sessions
|
|
# survive). The script exits 0 only after /health/ready answers through the LB.
|
|
# No credentials are printed.
|
|
ROOT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
cd "$ROOT_DIR"
|
|
|
|
# .env определяет, на каком порту публикуется LB (compose.yaml) и какие креды у
|
|
# хранилищ, поэтому значения берём оттуда же, а не из окружения вызывающего.
|
|
if [ -f .env ]; then
|
|
set -a
|
|
# shellcheck disable=SC1091
|
|
. ./.env
|
|
set +a
|
|
fi
|
|
|
|
COMPOSE_BIN=${COMPOSE_BIN:-docker compose}
|
|
PORT=${SERVER_PORT:-8080}
|
|
|
|
# shellcheck disable=SC2086
|
|
compose() {
|
|
# shellcheck disable=SC2086
|
|
$COMPOSE_BIN --env-file .env -f compose.yaml "$@"
|
|
}
|
|
|
|
# 1. State stores and broker: restart the running ones, then make sure they are
|
|
# healthy. Volumes are attached as before, nothing is dropped or re-seeded.
|
|
compose up -d --wait postgres redis seaweedfs broker
|
|
compose restart postgres redis seaweedfs broker
|
|
compose up -d --wait postgres redis seaweedfs broker
|
|
|
|
# 2. API replicas, worker and relay: restart in place and bring back any replica
|
|
# stopped by a fault-injection hook. The worker reconnects to the broker.
|
|
compose restart api worker relay
|
|
compose up -d --wait --no-deps api worker relay
|
|
|
|
# 3. Load balancer keeps its upstream; re-resolve in case addresses changed.
|
|
compose restart lb
|
|
|
|
# 4. Wait for readiness through the public entry point.
|
|
attempt=0
|
|
while [ "$attempt" -lt 60 ]; do
|
|
if curl -fsS --noproxy '*' -o /dev/null "http://127.0.0.1:${PORT}/health/ready"; then
|
|
printf 'restart.sh: stack restarted, http://127.0.0.1:%s/health/ready is ready\n' "$PORT"
|
|
exit 0
|
|
fi
|
|
attempt=$((attempt + 1))
|
|
sleep 1
|
|
done
|
|
|
|
printf 'restart.sh: /health/ready did not become ready through the LB\n' >&2
|
|
exit 1
|