Skip to content

Commit 737905c

Browse files
authored
Replace gunicorn with waitress (#1614)
This commit replaces the `gunicorn` WSGI server with `waitress`. It loses the statsd statistics, but gives us peace of mind. The setup was tested by commenting out the `python manage.py run` command in `docker-compose.yml`. Note that migrations need to be run for the index page to work via `podman compose exec web -- python manage.py migrate`. Rationale ========= Over the last few months, our dependency `gunicorn` has received a large amount of contributions written primarily by the maintainer with close to zero external review. None of these implemented features are anything we need: dirty workers, uWSGI protocol support, control socket, shared memory, .... Nor do I ever recall looking for any of these features in it. The sheer volume of code and the general format of changes also strongly reeks of LLM authorship or assistance. Of course, every maintainer is free to do with their software whatever they wish. But, as with any other dependency, I will evaluate any updates, keeping in mind that any dependency we have here has full access to our database and API. We do not need a WSGI server with regular feature development. We need one that works and is maintained - that is the only requirement. See the linked issue for more discussion. Fixes: #1613 Signed-off-by: Johannes Christ <jc@jchri.st>
1 parent 9c1c811 commit 737905c

6 files changed

Lines changed: 16 additions & 41 deletions

File tree

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,5 @@ RUN if [ $STATIC_BUILD = "TRUE" ] ; \
5656
then SECRET_KEY=dummy_value uv run python manage.py distill-local build --traceback --force ; \
5757
fi
5858

59-
CMD ["gunicorn", "--preload", "-b", "0.0.0.0:8000", \
60-
"pydis_site.wsgi:application", "-w", "2", "--statsd-host", \
61-
"graphite.default.svc.cluster.local:8125", "--statsd-prefix", "site", \
62-
"--config", "file:gunicorn.conf.py"]
59+
CMD ["waitress-serve", "--listen", "*:8000", \
60+
"--max-request-body-size=52428800", "pydis_site.wsgi:application"]

gunicorn.conf.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

manage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SiteManager:
3131
Manages the preparation and serving of the website for local use.
3232
3333
This class is used solely for setting up the development
34-
environment. In production, gunicorn is invoked directly
34+
environment. In production, the WSGI server is invoked directly
3535
and migrations are handled in an init container.
3636
3737
Usage:

pydis_site/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ the website:
5353
determine _which URLs will lead to which Django views_.
5454

5555
- [`wsgi.py`](./wsgi.py), which serves as an adapter for
56-
[`gunicorn`](https://github.com/benoitc/gunicorn),
56+
[`waitress`](https://github.com/Pylons/waitress),
5757
[`uwsgi`](https://github.com/unbit/uwsgi), or other application servers to run
5858
our application in production. Unless you want to test an interaction between
5959
our application and those servers, you probably won't need to touch this.

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ dependencies = [
1313
"django-prometheus==2.4.1",
1414
"django-simple-bulma==2.6.0",
1515
"djangorestframework==3.16.0",
16-
"gunicorn==24.1.1",
1716
"httpx==0.28.1",
1817
"markdown==3.8.2",
1918
"psycopg[binary]==3.2.9",
@@ -22,6 +21,7 @@ dependencies = [
2221
"python-frontmatter==1.1.0",
2322
"pyyaml==6.0.2",
2423
"sentry-sdk==2.33.0",
24+
"waitress==3.0.2",
2525
"whitenoise==6.9.0",
2626
]
2727

@@ -76,7 +76,6 @@ select = ["ANN", "B", "C4", "D", "DJ", "DTZ", "E", "F", "ISC", "INT", "N", "PGH"
7676
"pydis_site/apps/**/tests/test_*.py" = ["ANN", "D"]
7777
"static-builds/netlify_build.py" = ["T201"]
7878
"pydis_site/apps/api/tests/test_off_topic_channel_names.py" = ["RUF001"]
79-
"gunicorn.conf.py" = ["ANN", "D"]
8079
"pydis_site/apps/api/models/bot/off_topic_channel_name.py" = ["RUF001"]
8180

8281
[tool.taskipy.tasks]

uv.lock

Lines changed: 11 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)