forked from OpenIngenium/venue-agent-ampcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_venueserver.sh
More file actions
executable file
·89 lines (74 loc) · 1.76 KB
/
Copy pathstart_venueserver.sh
File metadata and controls
executable file
·89 lines (74 loc) · 1.76 KB
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
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
SCRIPT_FILE=$(realpath $0)
SCRIPT_DIR=$(dirname $SCRIPT_FILE)
VENV_DIR="$SCRIPT_DIR/venv3"
# Set text locale explicitly to avoid error when starting uvicorn
export LC_ALL='en_US.UTF-8'
export LANG='en_US.UTF-8'
usage() {
echo "
Usage: $0 -p PORT -f ENV_FILE
Options:
-p PORT (required): port used by VenueServer
-f ENV_FILE: path to a file that defines environment variables (required)
Example:
$0 -p 19443 -f config/europa_dev_envs.sh
"
}
input_error() {
usage
exit 1
}
while getopts ":p:f:" options; do
case "${options}" in
p)
PORT=${OPTARG}
;;
f)
ENV_FILE=${OPTARG}
;;
:)
echo "Error: -${OPTARG} requires a value."
input_error
;;
*)
break
;;
esac
done
if [[ -z "$ENV_FILE" ]]
then
input_error
fi
echo "ENV_FILE: $ENV_FILE"
if [[ -f "$ENV_FILE" ]]
then
source "$ENV_FILE"
else
echo "Error: file not found. $ENV_FILE"
exit 1
fi
if [[ -z $PORT ]]
then
echo "Error: PORT is required."
input_error
fi
if [ -d "$VENV_DIR" ]
then
echo "Use Python virtual env: $VENV_DIR"
source $VENV_DIR/bin/activate
else
echo "ERROR: Python virtual env does not exist: $VENV_DIR"
exit 1
fi
# Change PYTHONPATH to use local packages first.
# Need this to override the system level installation of Click.
# FASTAPI needs click version >= 7
export PYTHONPATH=$VENV_DIR/lib/python3.6/site-packages:$VENV_DIR/lib64/python3.6/site-packages:$ING_MTAK_DIR:$PYTHONPATH
IFS=':' read -ra PATHS <<< "$PYTHONPATH"
echo "PYTHONPATH"
for i in "${PATHS[@]}"; do
echo " - $i"
done
echo "Starting Venue Server on port $PORT"
$VENV_DIR/bin/python main.py --port $PORT