Introduce ConfigurableWorker to make uvicorn respect FORCE_SCRIPT_NAME

This commit is contained in:
puuu 2021-05-14 14:03:42 +09:00
parent 5bf725546b
commit c35c4eade9
2 changed files with 12 additions and 1 deletions

View 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):

11
src/paperless/workers.py Normal file
View File

@ -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 "",
}