Search code examples
djangogunicornuvicorn

How to specify uvicorn workers in gunicorn conf file


I run Django app with gunicorn using: gunicorn -c gunicorn.conf.py config.wsgi

## gunicorn.conf.py:

from os import environ

bind = '0.0.0.0:' + environ.get('PORT', '8000')
workers = environ.get('WORKERS', 8)
loglevel = 'info'
graceful_timeout = 300

Now I run it with gunicorn + uvicorn gunicorn -c gunicorn.conf.py config.asgi -k uvicorn.workers.UvicornWorker

and I want the add the -k uvicorn.workers.UvicornWorker to the gunicorn.conf.py


Solution

  • I added worker_class = 'uvicorn.workers.UvicornWorker', Documeted here

    from os import environ
    
    bind = '0.0.0.0:' + environ.get('PORT', '8000')
    workers = environ.get('WORKERS', 8)
    loglevel = 'info'
    graceful_timeout = 300
    worker_class = 'uvicorn.workers.UvicornWorker'