-
Notifications
You must be signed in to change notification settings - Fork 2
/
healthcheck.sh
executable file
·71 lines (61 loc) · 1.87 KB
/
healthcheck.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# Chargement des variables
source ./_env.conf
source ./_tput.conf
# Vérification du statut des containers
echo ""
echo "Checking containers:"
sleep 1
echo ""
echo "------------------------"
i=0
while [ $i -le 5 ]
do
HP=`docker inspect -f "{{ .State.Health.Status }}" postgres`
HM=`docker inspect -f "{{ .State.Health.Status }}" mongodb`
HF=`docker inspect -f "{{ .State.Health.Status }}" rdf4j`
HWS=`docker inspect -f "{{ .State.Health.Status }}" phis-ws`
HWA=`docker inspect -f "{{ .State.Health.Status }}" phis-webapp`
if [ $HP != "healthy" ]; then
echo "postgres: ${fgRed}${bold}$HP${reset}"
else
echo "postgres: ${fgGreen}${bold}$HP${reset}"
fi
if [ $HM != "healthy" ]; then
echo "mongodb: ${fgRed}${bold}$HM${reset}"
else
echo "mongodb: ${fgGreen}${bold}$HM${reset}"
fi
if [ $HF != "healthy" ]; then
echo "rdf4j: ${fgRed}${bold}$HF${reset}"
else
echo "rdf4j: ${fgGreen}${bold}$HF${reset}"
fi
if [ $HWS != "healthy" ]; then
echo "phis-ws: ${fgRed}${bold}$HWS${reset}"
else
echo "phis-ws: ${fgGreen}${bold}$HWS${reset}"
fi
if [ $HWA != "healthy" ]; then
echo "phis-webapp: ${fgRed}${bold}$HWA${reset}"
else
echo "phis-webapp: ${fgGreen}${bold}$HWA${reset}"
fi
echo "------------------------"
if [ $i -eq 5 ]
then
echo "ERROR: At less one container is unhealthy"
echo "PHIS doesn't work correctly, please check the status of container using 'docker ps' or try uninstall and reinstall the containers."
exit 1
fi
if [ $HP != "healthy" ] || [ $HWS != "healthy" ] || [ $HWA != "healthy" ]\
|| [ $HM != "healthy" ] || [ $HF != "healthy" ]
then
i=$((i+1))
sleep 7
else
echo ""
echo "All containers are available !"
i=6
fi
done