File size: 787 Bytes
5ed446f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

MAX_RETRIES=10

# Try running the docker and get the output
# then try getting /api

docker run -d -p 3000:3000 meting-api:${TAG}

if [[ $? -ne 0 ]]
then
    echo "Fail to run docker"
    exit 1
fi

RETRY=1

HTTP_CODE=$(curl -m 10 localhost:3000/api -w "%{http_code}" -o /dev/null)
while [[ $? -ne 0 || "$HTTP_CODE" -ne 200 ]] && [[ $RETRY -lt $MAX_RETRIES ]]; do
    echo "HTTP_CODE: ${HTTP_CODE}"
    sleep 5
    ((RETRY++))
    echo "RETRY: ${RETRY}"
    HTTP_CODE=$(curl -m 10 localhost:3000/api -w "%{http_code}" -o /dev/null)
done

if [[ $RETRY -gt $MAX_RETRIES ]]; then
    echo "Unable to run, aborted"
    exit 1
else
    if [[ $HTTP_CODE -ne 200 ]]; then
        echo "Api error"
        exit 1
    else
        echo "Successfully acquire /api, passing"
    fi
fi