-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·61 lines (46 loc) · 1.25 KB
/
start.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
#!/bin/bash
echo "== Changing working directory"
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
echo "== Starting..."
use_emulator=0
if [[ -n "${USE_EMULATOR}" && "${USE_EMULATOR}" == "1" ]]; then
use_emulator=1
fi
# If already in a virtual environment, exit it
if [ -z "${VIRTUAL_ENV}" ]; then
echo "== Leaving existing venv..."
deactivate
fi
if [ ! -d ./venv ]; then
echo "== Creating venv..."
python -m venv venv
else
echo "=== Using existing venv!"
fi
echo "== Activating venv..."
source ./venv/bin/activate
echo "== Installing dependencies..."
req_file="requirements.txt"
if [[ $use_emulator == "1" ]]; then
req_file="requirements.dev"
fi
pip install -r "$req_file"
echo "== Launching application..."
# Handle environment var args
if [ -z "${STATION_CRS}" ]; then
echo "===! STATION_CRS is not set." >&2
exit 1
fi
num_services="${NUM_SERVICES}"
if [ -z "${NUM_SERVICES}" ]; then
num_services=3
fi
if [[ ! "$num_services" =~ ^[2-9]$ ]]; then
echo "===! NUM_SERVICES does not contain a valid value. Must be a whole number between 2 and 9 inclusive." >&2
exit 1
fi
use_emulator_opt=""
if [[ $use_emulator == "1" ]]; then
use_emulator_opt="--emulate"
fi
python ./src/main.py $use_emulator_opt --services="$num_services" "$STATION_CRS"