Home > Net >  How to specify uvicorn workers in gunicorn conf file
How to specify uvicorn workers in gunicorn conf file

Time:05-19

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

CodePudding user response:

According to the docs the setting is named worker_class, the following should work

worker_class = 'uvicorn.workers.UvicornWorker'

CodePudding user response:

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'
  • Related