Run ASGI server instead of WSGI

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2023-03-22 11:45:56 +01:00
parent db5e3a3582
commit 805184767a
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
3 changed files with 22 additions and 2 deletions

View File

@ -8,7 +8,20 @@ python manage.py loaddata initial
nginx
if [ "$TFJM_STAGE" = "prod" ]; then
gunicorn -b 0.0.0.0:8000 --workers=2 --threads=4 --worker-class=gthread tfjm.wsgi --access-logfile '-' --error-logfile '-';
gunicorn -b 0.0.0.0:8000 \
--workers=2 \
--threads=4 \
--worker-class=uvicorn.workers.UvicornWorker \
tfjm.asgi \
--access-logfile '-' \
--error-logfile '-'
else
python manage.py runserver 0.0.0.0:8000;
gunicorn -b 0.0.0.0:8000 \
--workers=2 \
--threads=4 \
--worker-class=uvicorn.workers.UvicornWorker \
tfjm.asgi \
--access-logfile '-' \
--error-logfile '-' \
--reload
fi

View File

@ -20,4 +20,5 @@ ipython~=8.5.0
python-magic~=0.4.26
requests~=2.28.1
sympasoap~=1.1
uvicorn~=0.17
whoosh~=2.7

View File

@ -21,6 +21,7 @@ from django.contrib import admin
from django.urls import include, path
from django.views.defaults import bad_request, page_not_found, permission_denied, server_error
from django.views.generic import TemplateView
from participation.views import MotivationLetterView
from registration.views import HealthSheetView, ParentalAuthorizationView, PhotoAuthorizationView, \
ScholarshipView, SolutionView, SynthesisView, VaccineSheetView
@ -64,6 +65,11 @@ if 'cas_server' in settings.INSTALLED_APPS: # pragma: no cover
path('cas/', include('cas_server.urls', namespace="cas_server")),
]
if settings.DEBUG:
# Serve static files in DEBUG mode
import django.contrib.staticfiles.urls
urlpatterns += django.contrib.staticfiles.urls.urlpatterns
handler400 = bad_request
handler403 = permission_denied
handler404 = page_not_found