From a8d4ac9841fe7be63aed2ba33b171c21f0eb5f33 Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Sat, 14 Nov 2020 21:18:04 +0100 Subject: Banish UWSGI from my life, replace with gunicorn. This gets rid of various uwsgi stuff that we will no longer be needing. Enter; gunicorn. --- manage.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'manage.py') diff --git a/manage.py b/manage.py index d4748a3a..62352177 100755 --- a/manage.py +++ b/manage.py @@ -10,7 +10,6 @@ import django from django.contrib.auth import get_user_model from django.core.management import call_command, execute_from_command_line - DEFAULT_ENVS = { "DJANGO_SETTINGS_MODULE": "pydis_site.settings", "SUPER_USERNAME": "admin", @@ -156,10 +155,8 @@ class SiteManager: call_command("runserver", "0.0.0.0:8000") return - import pyuwsgi - - # Run uwsgi for production server - pyuwsgi.run(["--ini", "docker/uwsgi.ini"]) + # Run gunicorn for production server + os.system("gunicorn --preload -b 0.0.0.0:8000 pydis_site.wsgi:application --threads 8 -w 4") def main() -> None: -- cgit v1.2.3 From f57357e9f468797493e811e67998345ad4ee0e7a Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Sat, 14 Nov 2020 21:55:04 +0000 Subject: Don't call gunicorn using os.system, patch sys.argv and call the module --- manage.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'manage.py') diff --git a/manage.py b/manage.py index 62352177..446b1af3 100755 --- a/manage.py +++ b/manage.py @@ -7,6 +7,7 @@ import time from typing import List import django +import gunicorn.app.wsgiapp from django.contrib.auth import get_user_model from django.core.management import call_command, execute_from_command_line @@ -155,8 +156,18 @@ class SiteManager: call_command("runserver", "0.0.0.0:8000") return - # Run gunicorn for production server - os.system("gunicorn --preload -b 0.0.0.0:8000 pydis_site.wsgi:application --threads 8 -w 4") + # Patch the arguments for gunicorn + sys.argv = [ + "gunicorn", + "--preload", + "-b", "0.0.0.0:8000", + "pydis_site.wsgi:application", + "--threads", "8", + "-w", "4" + ] + + # Run gunicorn for the production server. + gunicorn.app.wsgiapp.run() def main() -> None: -- cgit v1.2.3 From 862a982115bc6feb46c082484740765b0eac5caa Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Sat, 5 Dec 2020 15:40:04 +0000 Subject: Update gunicorn configuration options --- manage.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'manage.py') diff --git a/manage.py b/manage.py index 446b1af3..36442eab 100755 --- a/manage.py +++ b/manage.py @@ -163,7 +163,10 @@ class SiteManager: "-b", "0.0.0.0:8000", "pydis_site.wsgi:application", "--threads", "8", - "-w", "4" + "-w", "4", + "--max-requests-jitter", "1000", + "--statsd_host", "graphite.default.svc.cluster.local:8125", + "--statsd_prefix", "site", ] # Run gunicorn for the production server. -- cgit v1.2.3 From 702afad1ee0973c8b46b641bba1665dc7c490b06 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Sat, 5 Dec 2020 15:43:21 +0000 Subject: Switch underscores for dashes in gunicorn CLI options --- manage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'manage.py') diff --git a/manage.py b/manage.py index 36442eab..3dee15c0 100755 --- a/manage.py +++ b/manage.py @@ -165,8 +165,8 @@ class SiteManager: "--threads", "8", "-w", "4", "--max-requests-jitter", "1000", - "--statsd_host", "graphite.default.svc.cluster.local:8125", - "--statsd_prefix", "site", + "--statsd-host", "graphite.default.svc.cluster.local:8125", + "--statsd-prefix", "site", ] # Run gunicorn for the production server. -- cgit v1.2.3 From 4e0ec7b5d7a7fe9cce28f795ef376435ed01c944 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Sun, 6 Dec 2020 12:43:50 +0000 Subject: Update manage.py Co-authored-by: Sebastiaan Zeeff <33516116+SebastiaanZ@users.noreply.github.com> --- manage.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'manage.py') diff --git a/manage.py b/manage.py index 3dee15c0..a025e7b1 100755 --- a/manage.py +++ b/manage.py @@ -164,7 +164,8 @@ class SiteManager: "pydis_site.wsgi:application", "--threads", "8", "-w", "4", - "--max-requests-jitter", "1000", + "--max-requests", "1000", + "--max-requests-jitter", "50", "--statsd-host", "graphite.default.svc.cluster.local:8125", "--statsd-prefix", "site", ] -- cgit v1.2.3 From 97d0ece403870a5a2184350608cda448808d70ac Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Thu, 25 Feb 2021 16:57:32 +0000 Subject: Reduce worker count from 4 to 2 We'll be creating a second site instance to allow for rolling restarts, so it makes sense to half this so when we double the requests we'll effectively have 4 workers again. --- manage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manage.py') diff --git a/manage.py b/manage.py index a025e7b1..fb5ee40c 100755 --- a/manage.py +++ b/manage.py @@ -163,7 +163,7 @@ class SiteManager: "-b", "0.0.0.0:8000", "pydis_site.wsgi:application", "--threads", "8", - "-w", "4", + "-w", "2", "--max-requests", "1000", "--max-requests-jitter", "50", "--statsd-host", "graphite.default.svc.cluster.local:8125", -- cgit v1.2.3