Not sure whether I should report this to cookiecutter-django or gunicorn
Currently my gunicorn is not reload after code change like this guy has
gunicorn==20.0.4 # via -r requirements.in
I use OSX 10.15.3 and run docker-compose -f local.yml up
Are there any people else except I and him having this problem?
@elcolie Replace this: /usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:8000 --chdir=/app -k uvicorn.workers.UvicornWorker --reload in compose/local/django/start
with this:
uvicorn config.asgi:application --host 0.0.0.0 --reload
I'll write the patch. Sorry, that first command was my fault. I couldn't understand why the application part wasn't working and then poof it started working... Forgot to write it after merged pr.
@Andrew-Chen-Wang Thank you very much. It works
Do you observe any CPU issues while running local? uvcorn constantly eats 10-20% CPU, my guess it has something to do with --reload.
Hmm I do, too. The only other option would be to try to use watchdog, which is apparently a better option according to encode/uvicorn#452 and in the commit encode/uvicorn#bfaf300 titled: "Use watchdog when available for file change detection."
I believe just adding watchdog to the requirements should work, right? @pySilver
I've tried latest uvicorn & watchgod, and I cant say it does drop cpu usage very much. What I've tried is also limit number of workers from 4 to 2 in development which now keeps cpu usage ~9-12%
For me, after a bit of testing, watchgod did drop CPU a bit. I'm also using an OS X and they're not known for being great performance wise... at least that's my experience. The number of workers should already be 2 (or even 1) if using that latter command, right, since --reload was used?
You are right, number of workers is not set for local env. Yeah, im on OSX too, so its also something to blame for performance drops.
Hi there, thanks for identifying the high CPU usage of uvicorn, while people are discussing the potential fix, could anyone tell me how to limit number of workers in local? thanks!
@xjlin0 If you're running with reload, I believe it should automatically be 1 worker for uvicorn. For the sake of CLI though, it should be --workers <int>
Most helpful comment
@elcolie Replace this:
/usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:8000 --chdir=/app -k uvicorn.workers.UvicornWorker --reloadin compose/local/django/startwith this:
uvicorn config.asgi:application --host 0.0.0.0 --reloadI'll write the patch. Sorry, that first command was my fault. I couldn't understand why the application part wasn't working and then poof it started working... Forgot to write it after merged pr.