generated from Start9Labs/hello-world-startos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhealth-check.sh
45 lines (41 loc) · 865 Bytes
/
health-check.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
#!/bin/sh
check_api(){
DURATION=$(</dev/stdin)
if (($DURATION <= 5000 )); then
exit 60
else
curl --silent --fail "itchysats.embassy:8000/api/alive" &>/dev/null
RES=$?
if test "$RES" != 0; then
echo "ItchySats API is unreachable" >&2
exit 1
fi
fi
}
check_web(){
DURATION=$(</dev/stdin)
if (($DURATION <= 5000 )); then
exit 60
else
curl --silent --fail itchysats.embassy:8000 &>/dev/null
RES=$?
if test "$RES" != 0; then
echo "The ItchySats UI is unreachable" >&2
exit 1
fi
fi
}
case "$1" in
api)
check_api
;;
web)
check_web
;;
*)
echo "Usage: $0 [command]"
echo
echo "Commands:"
echo " api"
echo " web"
esac