-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_script.sh
More file actions
executable file
·54 lines (45 loc) · 1.18 KB
/
Copy pathstart_script.sh
File metadata and controls
executable file
·54 lines (45 loc) · 1.18 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
#!/usr/bin/env bash
set -euo pipefail
HOST="0.0.0.0"
PORT="8000"
INSTALL_DEPS="0"
usage() {
cat <<'USAGE'
Usage: software/cloud/start_script.sh [--host <ip>] [--port <port>] [--install-deps]
Environment:
DATABASE_URL Optional. Defaults to local SQLite at software/cloud/data/fpgawand.sqlite3.
USAGE
}
while [[ $# -gt 0 ]]; do
case "$1" in
--host) HOST="${2:-}"; shift 2 ;;
--port) PORT="${2:-}"; shift 2 ;;
--install-deps) INSTALL_DEPS="1"; shift ;;
-h|--help) usage; exit 0 ;;
*)
echo "Unknown arg: $1" >&2
usage
exit 1
;;
esac
done
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV_DIR="${SCRIPT_DIR}/.venv"
if [[ ! -d "${VENV_DIR}" ]]; then
python3 -m venv "${VENV_DIR}"
fi
PY_BIN="${VENV_DIR}/bin/python"
PIP_BIN="${VENV_DIR}/bin/pip"
if [[ "${INSTALL_DEPS}" == "1" ]]; then
"${PY_BIN}" -m ensurepip --upgrade || true
"${PIP_BIN}" install --upgrade pip
"${PIP_BIN}" install \
"fastapi>=0.100.0" \
"uvicorn>=0.22.0" \
"pillow>=9.0.0" \
"numpy>=1.24.0" \
"sqlalchemy>=2.0.0" \
"psycopg2-binary>=2.9.0"
fi
cd "${SCRIPT_DIR}"
exec "${PY_BIN}" -m uvicorn main:app --host "${HOST}" --port "${PORT}"