]> git.parisson.com Git - teleforma.git/commitdiff
try uwsgi prod config by https://www.techatbloomberg.com/blog/configuring-uwsgi-produ...
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Mon, 28 Jun 2021 23:45:49 +0000 (01:45 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Mon, 28 Jun 2021 23:45:49 +0000 (01:45 +0200)
app/settings.py
app/wsgi.ini [new file with mode: 0644]
app/wsgi.sh
teleforma/views/core.py

index fae33cc9ebe93161cfdf078bd13f675ce22a7977..60cf799d5105c20668628913a3bc6e1c85541aa2 100644 (file)
@@ -280,6 +280,7 @@ SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
 # SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"
 #SESSION_ENGINE = "unique_session.backends.session_backend"
 UNIQUE_SESSION_WHITELIST = (1, 2042)
+SESSION_EXPIRE_AT_BROWSER_CLOSE = False
 
 RECAPTCHA_PUBLIC_KEY = '6Ldq5DgbAAAAADkKg19JXlhx6F1XUQDsrXfXqSP6'
 RECAPTCHA_PRIVATE_KEY = '6Ldq5DgbAAAAAOVDOeF2kH8i2e2VSNHpqlinbpAJ'
diff --git a/app/wsgi.ini b/app/wsgi.ini
new file mode 100644 (file)
index 0000000..5026c5a
--- /dev/null
@@ -0,0 +1,39 @@
+[uwsgi]
+
+uid = www-data
+gid = www-data
+
+strict = true
+master = true
+enable-threads = true
+vacuum = true                        ; Delete sockets during shutdown
+single-interpreter = true
+die-on-term = true                   ; Shutdown when receiving SIGTERM (default is respawn)
+need-app = true
+
+disable-logging = true               ; Disable built-in logging 
+log-4xx = true                       ; but log 4xx's anyway
+log-5xx = true                       ; and 5xx's
+
+harakiri = 60                        ; forcefully kill workers after 60 seconds
+py-callos-afterfork = true           ; allow workers to trap signals
+
+max-requests = 1000                  ; Restart workers after this many requests
+max-worker-lifetime = 3600           ; Restart workers after this many seconds
+reload-on-rss = 2048                 ; Restart workers after this much resident memory
+worker-reload-mercy = 60             ; How long to wait before forcefully killing workers
+
+cheaper-algo = busyness
+processes = 128                      ; Maximum number of workers allowed
+cheaper = 8                          ; Minimum number of workers allowed
+cheaper-initial = 16                 ; Workers created at startup
+cheaper-overload = 1                 ; Length of a cycle in seconds
+cheaper-step = 16                    ; How many workers to spawn at a time
+
+cheaper-busyness-multiplier = 30     ; How many cycles to wait before killing workers
+cheaper-busyness-min = 20            ; Below this threshold, kill workers (if stable for multiplier cycles)
+cheaper-busyness-max = 70            ; Above this threshold, spawn new workers
+cheaper-busyness-backlog-alert = 16  ; Spawn emergency workers if more than this many requests are waiting in the queue
+cheaper-busyness-backlog-step = 2    ; How many emergency workers to create if there are too many requests in the queue
+
+touch-reload = /srv/app/wsgi.py
index 863d1621cf03883404e0667b68870530abc1f74d..832a9e26194bacc803c4ad49b888650b359a4e16 100755 (executable)
@@ -3,7 +3,6 @@
 # paths
 app='/srv/app'
 manage=$app'/manage.py'
-wsgi=$app'/wsgi.py'
 static='/srv/static/'
 media='/srv/media/'
 src='/srv/src/'
@@ -53,7 +52,5 @@ else
 
     chown -R www-data: $debug_log
 
-    uwsgi --socket :$port --wsgi-file $wsgi --chdir $app --master \
-    --processes $processes \
-    --uid $uid --gid $gid --logto $uwsgi_log --touch-reload $wsgi
+    uwsgi /srv/app/wsgi.ini
 fi
index 0e490ae5bf5cd200ed2a699c9e1341e33ffa820a..d5b274d08eecb142f96995a28a0231b4db17290e 100644 (file)
@@ -55,6 +55,8 @@ from django.views.decorators.csrf import csrf_exempt
 from django.views.generic.base import TemplateResponseMixin, TemplateView, View
 from django.views.generic.detail import DetailView
 from django.views.generic.list import ListView
+from django.core.cache import cache
+
 from jsonrpc import jsonrpc_method
 from jsonrpc.proxy import ServiceProxy
 from rest_framework.permissions import IsAuthenticated