Skip to content

Commit

Permalink
⚡ [Performances] from WSGI to ASGI (fix GeotrekCE#4359)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpofredc committed Nov 13, 2024
1 parent 63f01f6 commit a958a25
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion debian/geotrek-api.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ StartLimitIntervalSec=30
StartLimitBurst=2

[Service]
ExecStart=/opt/geotrek-admin/bin/gunicorn --config=/opt/geotrek-admin/var/conf/gunicorn-geotrek_api.conf.py geotrek.wsgi
ExecStart=/opt/geotrek-admin/bin/gunicorn --config=/opt/geotrek-admin/var/conf/gunicorn-geotrek_api.conf.py geotrek.asgi -k uvicorn.workers.UvicornWorker
Restart=on-failure
User=geotrek
Group=geotrek
Expand Down
2 changes: 1 addition & 1 deletion debian/geotrek-ui.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ StartLimitIntervalSec=30
StartLimitBurst=2

[Service]
ExecStart=/opt/geotrek-admin/bin/gunicorn --config=/opt/geotrek-admin/var/conf/gunicorn-geotrek.conf.py geotrek.wsgi
ExecStart=/opt/geotrek-admin/bin/gunicorn --config=/opt/geotrek-admin/var/conf/gunicorn-geotrek.conf.py geotrek.asgi -k uvicorn.workers.UvicornWorker
Restart=on-failure
User=geotrek
Group=geotrek
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ RUN apt-get update -qq && apt-get -yqq full-upgrade && \

USER geotrek

CMD ["gunicorn", "geotrek.wsgi:application", "--bind=0.0.0.0:8000"]
CMD ["sh", "-c", "gunicorn geotrek.asgi:application --bind=0.0.0.0:8000 -k uvicorn.workers.UvicornWorker --workers ${GUNICORN_WORKERS:-1}"]
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ CHANGELOG
2.109.3+dev (XXXX-XX-XX)
----------------------------

**Performances**

- change deployment from standard WSGI to ASGI mode (asynchronous)


2.109.3 (2024-10-29)
----------------------------
Expand Down
14 changes: 14 additions & 0 deletions geotrek/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
ASGI config for Overhead Cables And Birdlife backend project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "geotrek.settings")

application = get_asgi_application()
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ click==8.1.3
# click-repl
# cligj
# fiona
# uvicorn
click-didyoumean==0.3.1
# via celery
click-plugins==1.1.1
Expand Down Expand Up @@ -206,6 +207,8 @@ gpxpy==1.6.2
# via mapentity
gunicorn==22.0.0
# via geotrek (setup.py)
h11==0.14.0
# via uvicorn
html5lib==1.1
# via weasyprint
idna==3.7
Expand Down Expand Up @@ -362,6 +365,7 @@ typing-extensions==4.12.2
# asgiref
# django-modeltranslation
# kombu
# uvicorn
tzdata==2024.2
# via
# backports-zoneinfo
Expand All @@ -375,6 +379,8 @@ urllib3==2.2.2
# via
# requests
# sentry-sdk
uvicorn==0.32.0
# via geotrek (setup.py)
vine==5.1.0
# via
# amqp
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def run(self):
"django-treebeard",
# prod,
'gunicorn',
'uvicorn',
'sentry-sdk',
'easy-thumbnails[svg]',
],
Expand Down

0 comments on commit a958a25

Please sign in to comment.