Listing MicroService
Mysql
docker pull mysql:latest
docker images
docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
docker ps
Connect
mysql -u root -p -h 127.0.0.1
Init
source ./sql/config.sql
Check
SHOW DATABASES;
use listing;
SHOW TABLES;
SELECT * FROM listing;
About Listing service
- get all listings api does not require authentication to verify consistency between users, but still need to provide a valid access token
- For C,U,D on specific listing, authentication is needed so that only owner of listing can make changes. To get the listing, a valid access token suffices.
How to build and run locally
- install deps
python3 -m pip install -r requirements.txt
- execute script
sql/config.sql
to initialize the database - run
flask run
The application should be running on localhost:5000
.
How to deploy
- Run
eb deploy
. Listing microservice is deployed on AWS elasticBeanstalk, and its database is using RDS.
Some important debugging tips about deploying
- when deploying, make sure the unzipping the file has
application.py
in it directly. If you are usingPyCharm
this might not be the case because of the/src
directory. - Make sure the naming is strictly
application.py
and inside the app, useapplication = app = Flask(..)
, and this is following rules of EBS. - Remember to configure ENV variables on EBS too.