The steps to set up the app will depend on whether you're (re)starting our production build or working on your own development environment.
In either case though you'll need to create/modify backend/.env
to look something like
DB_HOST='wouldntyouliketoknow'
DB_NAME='bigdata'
DB_USER='tt_request_bot'
DB_USER_PASSWORD='wouldntyouliketoknow'
The app is available to users inside the City network at https://trans-bdit.intra.prod-toronto.ca/traveltime-request/
Production code is located in /data/web
on the EC2 server.
- switch to user
tt_request_app
withsu tt_request_app
; you'll be asked for a password - pull any updates from the
deploy
branch
- Ports should already be assigned for back-end (8070) and for front-end (8071)
sudo nano /etc/nginx/sites-available/default
location /tt-request-backend/ {
proxy_pass http://localhost:8070/;
}
location /traveltime-request/ {
proxy_pass http://localhost:8071/;
alias /web/bdit_tt_request_app/frontend/build/static;
}
and then reload it using :
sudo nginx -s reload
There is a dev deployment available at https://trans-bdit.intra.prod-toronto.ca/dev-traveltime-request/. It listens to ports 8073 for the frontend and 8072 for the backend.
-
From the project root directory,
cd
into folderbackend
. -
If necessary, execute command
python3 -m venv venv/
to create a python virtual environment for the backend. -
Execute command
source venv/bin/activate
to use the virtual environment as the python interpreter for the backend. -
Execute command
pip3 install -r requirements.txt
to install the project dependencies listed in requirements.txt. -
Create a pgadmin bot (tt_request_bot
) to handle here travel time requests and give usage access to this bot for the schemashere
andhere_gis
, also change the path of this user to schemahere
, andpublic
. -
If necessary, edit the environment variables in
backend/.env
. -
Gunicorn is the service to be used to deploy a production version of the API server. Run
gunicorn --bind=0.0.0.0:8070 --timeout 10 --name=tt_request_app --workers=2 --threads=5 app:app -D
-
cd frontend
-
npm install
to install dependencies for the frontend listed inpackage.json
-
npm run build
to create an optimized production build -
pm2 serve dist 8071 -spa
to deploy the production build, where8071
is the port number assigned to the frontend application. This will also be the port to access the project application with.
- make it restart if EC2 fails
- https://askubuntu.com/questions/930589/running-upstart-script-on-17-04/1010398#1010398
cd frontend
npm install
- then concurrently:
npm start
; this will start a little server for the frontendnpm run build-dev
; this will build the source code and watch files for changes
cd backend
- create a
.env
file inbackend/
if you haven't aready. The variables you'll need to set are listed above. pip3 install -r requirements.txt
flask run -p 8072
This should deploy your build to https://trans-bdit.intra.prod-toronto.ca/dev-traveltime-request/