-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-preheating.sh
executable file
·78 lines (60 loc) · 1.85 KB
/
run-preheating.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Normally, the docker container will need to process data when it is started.
# This will cause a lot of time and redundant comutational effort to be wasted.
# So, we can preheat the docker images to avoid this problem. This script is
# part of the Dockerfile, and will be executed when the docker image is built.
echo "Preheating the docker image..."
# Run postgres in the background
./run-postgres.sh
# Check if previous command failed. If it did, exit
ret=$?
if [ $ret -ne 0 ]; then
echo "Failed to start postgres"
exit $ret
fi
# Run the migration script
poetry run python backend/manage.py migrate
# Check if previous command failed. If it did, exit
ret=$?
if [ $ret -ne 0 ]; then
echo "Migration failed"
exit $ret
fi
poetry run python backend/manage.py import_constructions ${LOCATION}
# Check if previous command failed. If it did, exit
ret=$?
if [ $ret -ne 0 ]; then
echo "Failed to load constructions data."
exit $ret
fi
poetry run python backend/manage.py import_accident_hotspots ${LOCATION}
# Check if previous command failed. If it did, exit
ret=$?
if [ $ret -ne 0 ]; then
echo "Failed to load accident hotspot data."
exit $ret
fi
poetry run python backend/manage.py import_green_waves ${LOCATION}
# Check if previous command failed. If it did, exit
ret=$?
if [ $ret -ne 0 ]; then
echo "Failed to load green wave data."
exit $ret
fi
poetry run python backend/manage.py import_velo_routes ${LOCATION}
# Check if previous command failed. If it did, exit
ret=$?
if [ $ret -ne 0 ]; then
echo "Failed to load velo routes data."
exit $ret
fi
poetry run python backend/manage.py import_landmarks ${LOCATION}
# Check if previous command failed. If it did, exit
ret=$?
if [ $ret -ne 0 ]; then
echo "Failed to load landmarks data."
exit $ret
fi
echo "Timestamp:"
echo $(date)
echo "Preheating complete!"