Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ [Performances] from WSGI to ASGI (fix #4359) #4364

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:-5}"]
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
Loading