29 lines
922 B
Bash
Executable File
29 lines
922 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
|
|
deadline=$(( $(date +%s) + 85 ))
|
|
docker compose restart postgres redis minio rabbitmq api worker reconciler
|
|
|
|
while [ "$(date +%s)" -lt "$deadline" ]; do
|
|
states=$(docker compose ps --all --format '{{.Service}} {{.State}} {{.Health}}' \
|
|
postgres redis minio rabbitmq api worker reconciler)
|
|
if echo "$states" | awk '
|
|
{ count[$1]++ }
|
|
$2 != "running" { failed = 1 }
|
|
$1 ~ /^(postgres|redis|minio|rabbitmq|api)$/ && $3 != "healthy" { failed = 1 }
|
|
END {
|
|
exit !(count["api"] >= 2 && count["postgres"] && count["redis"] &&
|
|
count["minio"] && count["rabbitmq"] && count["worker"] &&
|
|
count["reconciler"] && !failed)
|
|
}
|
|
'; then
|
|
exit 0
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
echo "Сервисы не восстановились за 85 секунд" >&2
|
|
docker compose ps --all >&2
|
|
exit 1
|