aboutsummaryrefslogtreecommitdiffstats
path: root/manage.py
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2020-11-14 21:55:04 +0000
committerGravatar Joe Banks <[email protected]>2020-11-14 21:55:04 +0000
commitf57357e9f468797493e811e67998345ad4ee0e7a (patch)
tree5bf6382b77f371c134f9eb00dbdd31b36f690bc2 /manage.py
parentUpdate azure-pipelines.yml to Python 3.9. (diff)
Don't call gunicorn using os.system, patch sys.argv and call the module
Diffstat (limited to 'manage.py')
-rwxr-xr-xmanage.py15
1 files changed, 13 insertions, 2 deletions
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: