Skip to content

Commit

Permalink
Fix django for production (#182)
Browse files Browse the repository at this point in the history
* Add gunicorn to requirements

* Add logging
  • Loading branch information
JeronimoMendes authored May 24, 2022
1 parent 5b9050d commit 19c0431
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions backend/Arquimedia/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
from pathlib import Path
import logging.config
import os
from dotenv import load_dotenv
from celery.schedules import crontab
Expand Down Expand Up @@ -187,3 +188,33 @@
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = 'Europe/Lisbon'

# Logging Configuration

# Clear prev config
LOGGING_CONFIG = None

# Get loglevel from env
LOGLEVEL = os.getenv('DJANGO_LOGLEVEL', 'info').upper()

logging.config.dictConfig({
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'console': {
'format': '%(asctime)s %(levelname)s [%(name)s:%(lineno)s] %(module)s %(process)d %(thread)d %(message)s',
},
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'console',
},
},
'loggers': {
'': {
'level': LOGLEVEL,
'handlers': ['console',],
},
},
})
1 change: 1 addition & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ django-cors-headers==3.7.0
django-rest-auth==0.9.5
django-timezone-field==4.2.3
djangorestframework==3.12.4
gunicorn==20.1.0
idna==3.2
kombu==5.2.4
oauthlib==3.1.1
Expand Down

0 comments on commit 19c0431

Please sign in to comment.