Skip to content

Commit

Permalink
Merge pull request #422 from python-discord/get_rid_of_uwsgi
Browse files Browse the repository at this point in the history
Get rid of UWSGI, replace with gunicorn
  • Loading branch information
lemonsaurus authored Nov 14, 2020
2 parents ca2503a + f57357e commit 04764a7
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 416 deletions.
5 changes: 1 addition & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ pydis_site/apps/home/tests
pydis_site/apps/staff/tests
CHANGELOG.md
CONTRIBUTING.md
docker
!docker/uwsgi.ini
!docker/wheels
docker-compose.yml
Dockerfile.local
Dockerfile
docs
htmlcov
LICENSE
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7-slim
FROM python:3.9-slim-buster

# Allow service to handle stops gracefully
STOPSIGNAL SIGQUIT
Expand Down
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ requests = "~=2.21"
pygments = "~=2.3.1"
wiki = "~=0.6.0"
pyyaml = "~=5.1"
pyuwsgi = {version = "~=2.0", sys_platform = "!='win32'"}
gunicorn = "~=20.0.4"
django-allauth = "~=0.41"
sentry-sdk = "~=0.14"
gitpython = "~=3.1.7"
Expand All @@ -38,7 +38,7 @@ pre-commit = "~=2.1"
unittest-xml-reporting = "~=3.0"

[requires]
python_version = "3.7"
python_version = "3.9"

[scripts]
start = "python manage.py run --debug"
Expand Down
456 changes: 238 additions & 218 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
displayName: 'Set Python Version'
name: PythonVersion
inputs:
versionSpec: '3.7.x'
versionSpec: '3.9.x'
addToPath: true

- task: DockerCompose@0
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
web:
build:
context: .
dockerfile: docker/Dockerfile
dockerfile: Dockerfile
command: ["run", "--debug"]
networks:
default:
Expand All @@ -45,6 +45,7 @@ services:
METRICITY_DB_URL: postgres://pysite:pysite@postgres:5432/metricity
SECRET_KEY: suitable-for-development-only
STATIC_ROOT: /var/www/static
DEBUG: 1

volumes:
staticfiles:
38 changes: 0 additions & 38 deletions docker/uwsgi.ini

This file was deleted.

146 changes: 0 additions & 146 deletions docs/deployment.md

This file was deleted.

18 changes: 13 additions & 5 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
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


DEFAULT_ENVS = {
"DJANGO_SETTINGS_MODULE": "pydis_site.settings",
"SUPER_USERNAME": "admin",
Expand Down Expand Up @@ -156,10 +156,18 @@ def run_server(self) -> None:
call_command("runserver", "0.0.0.0:8000")
return

import pyuwsgi

# Run uwsgi for production server
pyuwsgi.run(["--ini", "docker/uwsgi.ini"])
# 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:
Expand Down

0 comments on commit 04764a7

Please sign in to comment.