forked from HL7-DaVinci/test-ehr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerRunnerDev.sh
executable file
·56 lines (42 loc) · 1.74 KB
/
dockerRunnerDev.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
55
#!/bin/bash
# Handle closing application on signal interrupt (ctrl + c)
trap "kill $LOAD_DATA_PID $CONTINUOUS_BUILD_PID $SERVER_PID; gradle --stop; exit" INT
# Set environment variables
mkdir logs
# Reset log file content for new application boot
echo "*** Logs for 'gradle installBootDist --continuous' ***" > ./logs/builder.log
echo "*** Logs for 'gradle bootRun' ***" > ./logs/runner.log
# Print that the application is starting in watch mode
echo "Starting application in watch mode..."
# Start load data process once server is running
echo "Starting continuous data loader..."
( while ! grep -m1 "Started Application in " < ./logs/runner.log; do
sleep 1
done
echo "loading data into test-ehr..."
gradle loadData
# Continuous Load Data command whenever fhirResourcesToLoad directory changes
resources_modify_time=$(stat -c %Y fhirResourcesToLoad)
while sleep 1
do
new_resources_modify_time=$(stat -c %Y fhirResourcesToLoad)
if [[ "$resources_modify_time" != "$new_resources_modify_time" ]]
then
echo "loading data into test-ehr..."
gradle loadData
fi
resources_modify_time=$new_resources_modify_time
done ) & LOAD_DATA_PID=$!
# Start the continious build listener process
echo "starting continuous build listener..."
( gradle build --continuous | tee ./logs/builder.log ) & CONTINUOUS_BUILD_PID=$!
# Start server process once initial build finishes
( while ! grep -m1 'BUILD SUCCESSFUL' < ./logs/builder.log; do
sleep 1
done
echo "starting test-ehr server in debug mode..."
gradle bootRun -Pdebug 2>&1 | tee ./logs/runner.log ) & SERVER_PID=$!
# Handle application background process exiting
wait $CONTINUOUS_BUILD_PID $SERVER_PID $LOAD_DATA_PID
EXIT_CODE=$?
echo "application exited with exit code $EXIT_CODE..."