-
-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathtest-health
More file actions
executable file
·33 lines (30 loc) · 1.05 KB
/
test-health
File metadata and controls
executable file
·33 lines (30 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
docker compose ps
docker compose exec -T \
--user weblate \
weblate /app/bin/health_check
failure=0
# shellcheck disable=SC2013
for service in $(sed -n 's/^ \(weblate.*\):$/\1/p' docker-compose.yml); do
container_id="$(docker compose ps -q "$service")"
# shellcheck disable=SC2034
for i in $(seq 30); do
container_status="$(docker inspect --format '{{json .State.Health.Status }}' "$container_id")"
if [ "$container_status" != '"starting"' ]; then
break
fi
echo "Waiting for container $service to be up..."
sleep 1
done
container_status="$(docker inspect --format '{{json .State.Health.Status }}' "$container_id")"
echo "Container $service is $container_status"
if [ "$container_status" != '"healthy"' ]; then
failure=$((failure + 1))
docker inspect --format "{{json .State.Health }}" 67926a72d8b20e8ea379d7d03449fdde6d38bd39599b0b21b4fb880479049da3 | jq
echo
fi
done
if [ "$failure" -gt 0 ]; then
echo "Failed $failure services!"
exit 1
fi