Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
- Add psycopg dependency
- Add gunicorn config
- Configure Django logging
  • Loading branch information
wil93 committed Nov 4, 2024
1 parent 77fa8aa commit 24591e8
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ __pycache__/
old_app/
.env*
/static
gunicorn.access.log
gunicorn.error.log
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ django = "*"
django-allauth = "*"
python-dotenv = "*"
gunicorn = "*"
psycopg = "*"

[requires]
python_version = "3.12"
19 changes: 18 additions & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions gunicorn.conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
bind = "unix:/run/gunicorn.sock"
workers = 3

accesslog = "gunicorn.access.log"
errorlog = "gunicorn.error.log"

# Whether to send Django output to the error log
capture_output = True
# How verbose the Gunicorn error logs should be (debug, info, warning, error, critical)
loglevel = "info"
31 changes: 30 additions & 1 deletion itacpc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,33 @@
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
ALLOWED_HOSTS = ['teams24.itacpc.it', 'localhost']
STATIC_ROOT = BASE_DIR / 'static/'
STATIC_ROOT = '/var/www/django/static/'
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"root": {"level": "INFO", "handlers": ["file"]},
"handlers": {
"file": {
"level": "INFO",
"class": "logging.FileHandler",
"filename": "/var/log/django.log",
"formatter": "app",
},
},
"loggers": {
"django": {
"handlers": ["file"],
"level": "INFO",
"propagate": True
},
},
"formatters": {
"app": {
"format": (
u"%(asctime)s [%(levelname)-8s] "
"(%(module)s.%(funcName)s) %(message)s"
),
"datefmt": "%Y-%m-%d %H:%M:%S",
},
},
}
4 changes: 1 addition & 3 deletions systemd/gunicorn.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ User=itacpc
Group=www-data
WorkingDirectory=/home/itacpc/teams
ExecStart=/home/itacpc/.local/share/virtualenvs/teams-_GRcvIg0/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
--config ./gunicorn.conf.py \
itacpc.wsgi:application

[Install]
Expand Down

0 comments on commit 24591e8

Please sign in to comment.