forked from indico/indico-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·51 lines (38 loc) · 973 Bytes
/
test.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
#!/bin/bash
# cp indico-web.env.sample indico-web.env
# sed ...
URL=http://localhost:9090/category/0/statistics
URL2=http://localhost:9090/system-info
TIMEOUT=120
# avoid building obsolete static image
sed -i -E 's/build: indico\/static/image: tianon\/true/' docker-compose.yml
# make sure the cluster is down
docker-compose down
# then try to bring it up
docker-compose up -d
timeout_handler() {
# SIGALRM caught, let's just exit
exit 1
}
trap timeout_handler ALRM
# this is the timer process that will send SIGALRM
pid=$$
(
sleep $TIMEOUT
echo 'Timeout! Killing process'
kill -s ALRM $pid
) &
alarm=$!
while [[ "$(curl -L --max-time 10 -s -o /dev/null -w ''%{http_code}'' $URL)" != "200" ]]; do
sleep 30;
echo 'Waiting...'
done
# Print response from server, for clarity
curl -fsSL $URL | jq .
curl -fsSL $URL2 | jq .
# yay!
echo 'Indico seems alive!'
# remove timer
kill -s TERM $alarm > /dev/null 2>&1
docker-compose down
exit 0