From c05efa783b6f9f312af0cefaa7ba49870690c8d3 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 3 May 2020 17:28:02 +0100 Subject: [PATCH] Add multiple workers and threads Also move gunicorn config into file --- Dockerfile | 2 +- scripts/test.sh | 2 ++ website/gunicorn.conf.py | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 website/gunicorn.conf.py diff --git a/Dockerfile b/Dockerfile index 92053ae..4faf2a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,4 +23,4 @@ RUN ./scripts/setup-python.sh RUN rm -rf ./static EXPOSE 8000 -CMD ["gunicorn", "-b", "0.0.0.0:8000", "--preload", "--access-logfile", "/dev/stdout", "website.wsgi:application"] +CMD ["gunicorn", "-c", "website/gunicorn.conf.py", "--access-logfile", "/dev/stdout", "website.wsgi:application"] diff --git a/scripts/test.sh b/scripts/test.sh index 0d8f351..e86178c 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -19,3 +19,5 @@ isort -rc -c website/ mypy website/ eslint static/src/js + +gunicorn --check-config -c website/gunicorn.conf.py website.wsgi:application diff --git a/website/gunicorn.conf.py b/website/gunicorn.conf.py new file mode 100644 index 0000000..59e593b --- /dev/null +++ b/website/gunicorn.conf.py @@ -0,0 +1,6 @@ +import multiprocessing + +bind = "0.0.0.0:8000" +workers = multiprocessing.cpu_count() * 2 + 1 +threads = 2 +preload = True