-
-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathdstart
More file actions
executable file
·77 lines (63 loc) · 2.6 KB
/
Copy pathdstart
File metadata and controls
executable file
·77 lines (63 loc) · 2.6 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
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 service-name (book, assignment, author, admin)"
echo "This script starts a single service in the rs folder in development mode"
echo "It will watch for changes to files and restart itself. You can use pdb and set_trace()"
echo "to debug your code."
exit 1
fi
set -e
SERVICE=$1
# these environment variables need to be set differentlty for running the servers on the host machine
# instead of in the docker container, so fix them up here
export RUNESTONE_PATH=.
export BOOK_PATH=~/Runestone/books
export REDIS_URI=redis://localhost:6379/0
cd $RUNESTONE_PATH
# check to see if the rs virtual environment is active
if [[ -z "$VIRTUAL_ENV" && $VIRTUAL_ENV == *"rs/.venv" ]]; then
echo "The rs virtual environment is not active. Please activate it first."
exit 1
fi
# kill previously running servers if present
if [[ "$SERVICE" == "all" || "$SERVICE" == "stopall" ]]; then
lsof -t -i tcp:8100 | xargs kill
lsof -t -i tcp:8101 | xargs kill
lsof -t -i tcp:8102 | xargs kill
lsof -t -i tcp:8104 | xargs kill
# wait for the servers to stop
sleep 5
fi
if [ "$SERVICE" == "all" ]; then
docker compose --profile dev up -d nginx_dstart_dev
uvicorn rsptx.book_server_api.main:app --host 0.0.0.0 --port 8100 --reload &
uvicorn rsptx.assignment_server_api.core:app --host 0.0.0.0 --port 8101 --reload &
uvicorn rsptx.author_server_api.main:app --host 0.0.0.0 --port 8102 --reload &
uvicorn rsptx.admin_server_api.core:app --host 0.0.0.0 --port 8104 --reload &
fi
# check to see if the SERVICE is book
if [ "$SERVICE" == "book" ]; then
echo "Starting the book service on port 8100"
uvicorn rsptx.book_server_api.main:app --host 0.0.0.0 --port 8100 --reload
exit 0
fi
if [ "$SERVICE" == "assignment" ]; then
echo "Starting the assignment service on port 8101"
uvicorn rsptx.assignment_server_api.core:app --host 0.0.0.0 --port 8101 --reload
exit 0
fi
if [ "$SERVICE" == "author" ]; then
echo "Starting the author service on port 8102"
uvicorn rsptx.author_server_api.main:app --host 0.0.0.0 --port 8102 --reload
exit 0
fi
# The admin server answers every URL no other server claims (see its
# routers/root.py), so the dev proxy needs it running for anything that is not
# /ns, /assignment or /author to resolve.
if [ "$SERVICE" == "admin" ]; then
echo "Starting the admin service on port 8104"
uvicorn rsptx.admin_server_api.core:app --host 0.0.0.0 --port 8104 --reload
exit 0
fi
# todo: start up a local nginx server to serve the static files
# todo: with nginx running allow multiple servers to run