[Django]-Setting number of gunicorn workers in django settings.py

0👍

You can use the -c command to specify a configuration file (written in python):

http://docs.gunicorn.org/en/latest/configure.html#settings

Since this is a python file, you can from django.conf import settings and do

workers = settings.GUNICORN_WORKERS
👤Jj.

0👍

Just add:

run_gunicorn --workers=4

You can make the command a unix alias if you want to have the number of workers default to this.

0👍

You’re not supposed to do python manage.py run_gunicorn.

do gunicorn project_name.wsgi -b 0.0.0.0:8000 -w 10

or do python -m gunicorn project_name.wsgi -b 0.0.0.0:8000 -w 10

if you’re keen on using manage.py command read this on how to create a custom management command, create when that uses the subprocess module’s Popen method to call one of commands i’ve written above

Leave a comment