Skip to content

Commit

Permalink
Re-structured logging; updated requirements & Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
brystmar committed Feb 21, 2020
1 parent 7511f75 commit 27ea486
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 75 deletions.
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ COPY . /usr/src/app
WORKDIR /usr/src/app
RUN pip install -r requirements.txt

EXPOSE 8000

CMD [ "gunicorn", "--workers=1", "--timeout=60", "--name=breadsheet-backend", "main:breadapp" ]
CMD [ "gunicorn", "--workers=1", "--timeout=30", "--name=breadsheet-backend", "main:breadapp" ]

# CMD [ "export", "FLASK_APP=main.py" ]
# CMD [ "flask run" ]
Expand Down
2 changes: 1 addition & 1 deletion backend/functions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Collection of functions used across the breadsheet project."""
from main import logger
from backend.global_logger import logger
from backend.models import Recipe
from datetime import datetime, timedelta
from pynamodb.attributes import ListAttribute
Expand Down
4 changes: 2 additions & 2 deletions backend/global_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from os import path, mkdir

basedir = path.abspath(path.dirname(__file__))
local = 'pycharm' in basedir.lower()
# local = 'pycharm' in basedir.lower()
local = True

# initialize logging
if local:
Expand Down Expand Up @@ -36,4 +37,3 @@
logger.info("\n=======================================\n\n")
logger.info(f"Global logging initialized! Level: {logger.getEffectiveLevel()}")
logger.info(f"local = {local}")
print(f"Name: {__name__}")
2 changes: 1 addition & 1 deletion backend/meta_routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from main import logger
from backend.global_logger import logger
from flask import request
from flask_restful import Resource
from os import path
Expand Down
2 changes: 1 addition & 1 deletion backend/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from main import logger
from backend.global_logger import logger
from backend.config import Config, local
from datetime import datetime, timedelta
from pynamodb.models import Model
Expand Down
2 changes: 1 addition & 1 deletion backend/recipe_routes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Defines recipe-related endpoints for the front end to consume."""
from main import logger
from backend.global_logger import logger
from backend.functions import generate_new_id
from backend.models import Recipe
from flask import request
Expand Down
4 changes: 2 additions & 2 deletions backend/replacement_routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from main import logger
from backend.global_logger import logger
from backend.models import Replacement
from flask import request
from flask_restful import Resource, reqparse
Expand Down Expand Up @@ -49,7 +49,7 @@ def put(self, scope, old_value) -> json:

if scope not in ('all', 'ingredients', 'directions'):
error_msg = f"Invalid scope: {scope}."
logger.debug(f"{error_msg}\n{e}")
logger.debug(f"{error_msg}")
return {'message': 'Validation Error', 'data': error_msg}, 422

# Retrieve the record
Expand Down
2 changes: 1 addition & 1 deletion backend/step_routes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Defines step-related endpoints for the front end to consume."""
from main import logger
from backend.global_logger import logger
from backend.models import Step, Recipe
from flask import request
from flask_restful import Resource, reqparse
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ services:
image: amazon/dynamodb-local:1.12.0
ports:
- 8008:8008
command: ["-jar", "DynamoDBLocal.jar", "-sharedDb", "-inMemory", "-port 8008"]
command: ["-jar", "DynamoDBLocal.jar", "-sharedDb", "-inMemory", "-port", "8008"]
1 change: 0 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# External packages
from flask import redirect, request
from flask_restful import Api
from gunicorn import http

# App components
from backend import create_app
Expand Down
100 changes: 43 additions & 57 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,80 +1,66 @@
aniso8601==8.0.0
arrow==0.13.1
arrow==0.15.5
atomicwrites==1.3.0
attrs==19.1.0
attrs==19.3.0
blinker==1.4
boto3==1.11.12
botocore==1.14.12
CacheControl==0.12.5
cachetools==3.1.0
certifi==2019.3.9
boto3==1.12.3
botocore==1.15.3
CacheControl==0.12.6
cachetools==4.0.0
certifi==2019.11.28
chardet==3.0.4
Click==7.0
configparser==3.7.4
dateparser==0.7.1
docutils==0.14
dominate==2.3.5
configparser==4.0.2
dateparser==0.7.2
docutils==0.16
dominate==2.4.0
env-tools==2.2.0
ez-setup==0.9
firebase-admin==2.17.0
Flask==1.1.1
Flask-Moment==0.9.0
Flask-RESTful==0.3.8
Flask-WTF==0.14.3
google-api-core==1.14.0
google-api-python-client==1.7.9
google-auth==1.6.3
google-auth-httplib2==0.0.3
google-cloud==0.34.0
google-cloud-core==1.0.2
google-cloud-firestore==1.4.0
google-cloud-storage==1.18.0
google-resumable-media==0.3.2
googleapis-common-protos==1.6.0
grpcio==1.26.0
grpcio==1.27.2
gunicorn==20.0.4
httplib2==0.17.0
idna==2.8
importlib-metadata==0.18
idna==2.9
importlib-metadata==1.5.0
itsdangerous==1.1.0
Jinja2==2.11.1
jmespath==0.9.4
Mako==1.0.7
Markdown==3.1.1
MarkupSafe==1.1.0
moment==0.8.2
more-itertools==7.0.0
msgpack==0.6.1
packaging==19.0
passlib==1.7.1
Pint==0.9
pluggy==0.12.0
protobuf==3.7.1
py==1.8.0
pyasn1==0.4.5
pyasn1-modules==0.2.4
pynamodb==4.0.0
pyparsing==2.4.1.1
pyperclip==1.7.0
pytest==5.1.1
python-dateutil==2.8.0
python-dotenv==0.10.5
Mako==1.1.1
Markdown==3.2.1
MarkupSafe==1.1.1
more-itertools==8.2.0
msgpack==1.0.0
packaging==20.1
passlib==1.7.2
pluggy==0.13.1
protobuf==3.11.3
py==1.8.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pynamodb==4.3.1
pyparsing==2.4.6
pytest==5.3.5
python-dateutil==2.8.1
python-dotenv==0.11.0
python-editor==1.0.4
pytz==2018.9
regex==2019.6.2
requests==2.22.0
pytz==2019.3
regex==2020.2.20
requests==2.23.0
rsa==4.0
s3transfer==0.3.3
six==1.12.0
soupsieve==1.9.1
testfixtures==6.11.0
six==1.14.0
soupsieve==1.9.5
testfixtures==6.13.1
times==0.7
tini==3.0.1
tzlocal==1.5.1
uritemplate==3.0.0
urllib3==1.24.3
tzlocal==2.0.0
uritemplate==3.0.1
urllib3==1.25.8
visitor==0.1.3
wcwidth==0.1.7
Werkzeug==0.15.5
wcwidth==0.1.8
Werkzeug==1.0.0
WTForms==2.2.1
zipp==0.5.2
zipp==3.0.0
9 changes: 5 additions & 4 deletions templates/default_error.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
</head>
<body>
<div class="container">
<p>
<p>
<h1>You found the default error page!</h1>
</p>
Something happened, and it's probably your fault.
</p>
Something happened, and it's probably your fault.
<p>
<img src="https://breadsheet-public.s3-us-west-2.amazonaws.com/computer_fire.gif"/>
<img src="https://breadsheet-public.s3-us-west-2.amazonaws.com/computer_fire.gif"
alt="Computer on fire"/>
</p>
</div>
</body>
Expand Down

0 comments on commit 27ea486

Please sign in to comment.