-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
39 lines (31 loc) · 852 Bytes
/
start.sh
File metadata and controls
39 lines (31 loc) · 852 Bytes
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
#!/usr/bin/env bash
set -e
echo "This script requires that the Docker containers are already running."
ask() {
while true; do
read -rp "$1 (y/n): " yn
case $yn in
[Yy]* ) return 0 ;;
[Nn]* ) return 1 ;;
* ) echo "Please answer yes or no." ;;
esac
done
}
# Activate environment
if [ ! -d "venv" ]; then
echo "Virtual environment not found!"
exit 1
fi
source ./venv/bin/activate
if ask "Start server in background?"; then
nohup python3 -m uvicorn api.server:app \
--host 0.0.0.0 \
--port 8080 \
--log-level debug \
> api.log 2>&1 &
echo "Server started in background."
echo "Logs: api.log"
exit 0
fi
echo "Starting server in the foreground..."
python3 -m uvicorn api.server:app --host 0.0.0.0 --port 8080 --log-level debug