-
Notifications
You must be signed in to change notification settings - Fork 15
/
cron.sh
executable file
·54 lines (36 loc) · 1.14 KB
/
cron.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
#!/bin/bash
# This process runs in a different port so it has endpoints that are not protected and can,
# therefore, be used to create statistics
port=${STATISTICS_PORT:-8080}
LIMIT=60 # 60 seconds waiting for a response
INTERVAL=5
echo "Build artifact"
./server/gradlew build -p server -x test
virtualenv venv -p python3
source venv/bin/activate
echo "Install python dependencies"
pip3 install -r misc/python/requirements.txt
echo "Start the API in the port $port"
java -jar server/build/libs/statistics-server.jar --spring.profiles.active=cron --server.port=${port} &
elapsed=0
while [ 1 ]; do
sleep "$INTERVAL"
response=$(curl -s "http://localhost:${port}/actuator/health")
# Check if response length is greater than 0
if [ "${#response}" -gt 0 ]
then
echo "API Started"
break
fi
((elapsed+=INTERVAL))
echo "Waiting for the API to start ${elapsed}/${LIMIT}"
if [ "$elapsed" -gt "$LIMIT" ]
then
echo "API not started. Finishing with error."
exit 1
fi
done
echo "Get database export and generate statistics"
source scripts/generate_all_statistics.sh
echo "Success"
exit 0