Skip to content

Commit 0c2d83c

Browse files
committed
Preload options from settings
1 parent 0e07356 commit 0c2d83c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

django_uwsgi/management/commands/runuwsgi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ def handle(self, *args, **options):
2525
self.http_port = None
2626
self.socket_addr = v
2727

28+
# Preload options from settings
29+
for option, value in getattr(settings, "UWSGI", {}):
30+
envvar = option.upper().replace("-", "_")
31+
if isinstance(value, bool):
32+
value = "true" if value else "false"
33+
os.environ.setdefault("UWSGI_%s" % envvar, str(value))
34+
2835
# load the Django WSGI handler
2936
os.environ.setdefault('UWSGI_MODULE', '%s.wsgi' % django_project)
3037
# DJANGO settings

docs/command.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ runuwsgi options:
1212
-----------------
1313

1414
http
15-
----
15+
----
1616

1717
.. code-block:: sh
1818
@@ -29,4 +29,5 @@ socket
2929
Other options
3030
-------------
3131

32-
Any other options can be passed via environment variables, prefixed with `UWSGI_`
32+
Any other options can be passed via environment variables, prefixed with `UWSGI_` and converted
33+
to upper-case, or as key-value pairs in a dictionary named `UWSGI` in settings.

0 commit comments

Comments
 (0)