-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathhealth-checks
64 lines (44 loc) · 1.29 KB
/
health-checks
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
#!/bin/bash
# Purpose: Application Health Check For Zero Down Time
dns_name="localhost"
health_check_path="/api/v1/users/"
# This IPV4 Address of machine
echo "domain name is "$dns_name""
# DNS+HealthCheck PAth combined
echo "health check path is "$dns_name""$health_check_path""
# Services Status
echo "Restarting UWSGI"
systemctl restart uwsgi
sleep 10
echo "UWSGI STATUS" && systemctl is-active uwsgi
sleep 5
echo "Restarting SUPERVISOR"
systemctl restart supervisor
sleep 5
echo "SUPERVISOR STATUS" && systemctl is-active supervisor
sleep 10
echo "Restarting NGINX"
systemctl restart nginx
sleep 5
echo "NGINX STATUS" && systemctl is-active nginx
# Wait Time For Application Up & Running
wait="60"
echo "Wait Time For Application Up & Running, Please wait "$wait" sec than Application Health Checks will begin ..."
# bash while loop
sleep "$wait"
echo "Checking Health Checks with curl let's see!"
# Now health checking
curl ""$dns_name""$health_check_path""
while true
do
response=$(curl -I ""$dns_name""$health_check_path"" | head -n1 | awk '{print $2}')
echo "This is application Status Code via Curl "$response""
if [ $response -eq 200 ] ; then
echo "$(date -u) app is available"
exit 0
else
echo "$(date -u) app is unavailable"
exit 1
fi
done
#END