-
Notifications
You must be signed in to change notification settings - Fork 3
Frontend
- update react:
npm run build
andsudo systemctl restart nginx
- update flask:
pkill gunicorn
, ortmux
and restart gunicorn on the correct port (dangerous, read details below before you do it)
We seted up elastic public IP address for our EC2 instances, so its IP address will never change.
- Elastic Public IP:
http://3.94.25.91
- SSH:
ec2-3-94-25-91.compute-1.amazonaws.com
- React: main page + live render. Public IP:
http://ip/
orhttp://ip/xxx
- Flask: listen for other ports. Public IP:
http://ip/api/xxx
, notice the /api prefix before everything. You will need to write that in the flask appapi.py
- Gunicorn: host flask, easy to start new ports
- Nginx: web serving, connect gunicorn, reverse proxying, caching. But basically, all you need to know is it redirect and make the port
http://127.0.0.1:8000
visiable athttp://ip
, which is the react contents, andhttp://127.0.0.1:8000/api
athttp://ip/api
, which is the flask ports.
Coding should be done on EC2 directly for better testing purposes, and the venv is created at /home/ubuntu/MathSearch/front-end/venv
already
If you have to test on your local for some reason, manually create venv with requirements.txt, and to activate the virtual environment
put your venv in /home/ubuntu/MathSearch/front-end
and cd into it
source venv/bin/activate
after npm run build
sudo service nginx restart
which is the same as sudo systemctl restart nginx
first kill gunicorn, grep pid and kill that pid
it should be something like: 34702 pts/39 S+ 0:00 /.../python3 /.../gunicorn -b 127.0.0.1:8000 api:app
sudo ps ax | grep 8000
kill <gunicorn_pid>
or
pkill gunicorn
then
cd ~/MathSearch/front-end/web
tmux
gunicorn -b 127.0.0.1:8000 api:app
You must be in /web
to let gunicorn start app
-b stands for bind which specify the IP address
please run it within tmux so we can always open the terminal again to see gunicorn debug log.
above command start gunicorn which run flask, do NOT end this process
Can go to the Public IP address of EC2 on the browser to see the default nginx landing page
sudo systemctl start nginx
sudo systemctl enable nginx
Option 1:
visit 127.0.0.1:8000/test
Option 2:
curl localhost:8000/test
Option 3:
use any unused port
gunicorn -b 127.0.0.1:8001 api:app
if get [ERROR] Connection in use: ('127.0.0.1', 8000), you need to stop public deployment to deploy to local, do a pid kill
sudo systemctl status nginx
sudo nginx -t
sudo service nginx restart
There's no references anymore. Too many sites had been used during debug. Just slack if you need support on anything.
/etc/nginx/nginx.conf
- (unused)
/lib/systemd/system/nginx.service
- (unused)
/etc/nginx/sites-available/MathSearch
To test connection, run below (notice the "-" on the second option). It should display directory in s3 buckets or cat the file.
option 1
aws s3 ls s3://mathsearch-intermediary
option 2
aws s3 cp s3://mathsearch-intermediary/test.txt -