Files
mtusi2026lab4/scripts/restart.sh
T

37 lines
705 B
Bash
Executable File

#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
compose() {
docker compose \
-f compose.yaml \
-f compose.s3.yaml \
--env-file .env \
"$@"
}
echo "Stopping LB and API..."
compose stop --timeout 5 lb api
echo "Restarting PostgreSQL, Redis and S3..."
compose restart --timeout 10 postgres redis s3
echo "Waiting for PostgreSQL..."
attempt=0
until compose exec -T postgres \
pg_isready -U messenger -d messenger >/dev/null 2>&1
do
attempt=$((attempt + 1))
if [ "$attempt" -ge 20 ]; then
echo "PostgreSQL did not become ready" >&2
exit 1
fi
sleep 1
done
echo "Starting API and LB..."
compose start api lb
echo "Restart hook completed."