-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
dstart
executable file
·75 lines (61 loc) · 2.48 KB
/
dstart
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
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 service-name (book, assignment, author, runestone)"
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:8103 | 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 &
python bases/rsptx/web2py_server/web2py.py --no-gui --password "<recycle>" --ip 0.0.0.0 --port 8103 &
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
if [ "$SERVICE" == "runestone" ]; then
echo "Starting the web2py service on port 8103"
cd bases/rsptx/web2py_server
python web2py.py --no-gui --password "<recycle>" --ip 0.0.0.0 --port 8103
exit 0
fi
# todo: start up a local nginx server to serve the static files
# todo: with nginx running allow multiple servers to run