]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Introduce ConfigurableWorker to make uvicorn respect FORCE_SCRIPT_NAME
authorpuuu <puuu@users.noreply.github.com>
Fri, 14 May 2021 05:03:42 +0000 (14:03 +0900)
committerpuuu <puuu@users.noreply.github.com>
Fri, 14 May 2021 05:44:13 +0000 (14:44 +0900)
gunicorn.conf.py
src/paperless/workers.py [new file with mode: 0644]

index 995b4fb9d15980057f5bac1545cc875d97d5a16f..bcc12490ebe5a24800527e49886f469020077684 100644 (file)
@@ -2,7 +2,7 @@ import os
 
 bind = '0.0.0.0:8000'
 workers = int(os.getenv("PAPERLESS_WEBSERVER_WORKERS", 2))
-worker_class = 'uvicorn.workers.UvicornWorker'
+worker_class = 'paperless.workers.ConfigurableWorker'
 timeout = 120
 
 def pre_fork(server, worker):
diff --git a/src/paperless/workers.py b/src/paperless/workers.py
new file mode 100644 (file)
index 0000000..4f2f080
--- /dev/null
@@ -0,0 +1,11 @@
+import os
+from uvicorn.workers import UvicornWorker
+from django.conf import settings
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "paperless.settings")
+
+
+class ConfigurableWorker(UvicornWorker):
+    CONFIG_KWARGS = {
+        "root_path": settings.FORCE_SCRIPT_NAME or "",
+    }