Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug mode? #3

Closed
wshayes opened this issue Feb 19, 2019 · 8 comments
Closed

Debug mode? #3

wshayes opened this issue Feb 19, 2019 · 8 comments

Comments

@wshayes
Copy link

wshayes commented Feb 19, 2019

Trying to figure out how to turn on auto-reloading (e.g. debug mode) while using docker. I develop in the docker container by volume mounting the app directory into the docker container so any changes I make to the code are available immediately inside the running docker container. I can't figure out how to start debug mode using gunicorn with uvicorn.

Any ideas?

PS Great project and thanks!

@rudmac
Copy link

rudmac commented Feb 25, 2019

just create a env GUNICORN_CMD_ARGS="--reload"

http://docs.gunicorn.org/en/stable/settings.html#reload

or you can insert into gunicorn-conf.py

reload = True

@wshayes
Copy link
Author

wshayes commented Feb 25, 2019

Aarrgghhh! Yes that works great - read somewhere that didn’t work and didn’t test it. Shame on me.

Thanks!

Thanks also for the env tip - works great with Docker compose.

@tiangolo
Copy link
Owner

tiangolo commented Mar 7, 2019

@wshayes

Great project and thanks!

Awesome! I'm glad it's working for you.

@rudmac Thanks for your help here! It's very appreciated. 👏 🌮


There's a new integrated script /start-reload.sh specifically for this.

It runs only Uvicorn with --reload, optimal for development.

Check the updated docs here: https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker#development-live-reload

@wshayes
Copy link
Author

wshayes commented Mar 7, 2019

Thanks - I'll update the writeup I made for it: https://medium.com/@williamhayes/fastapi-starlette-debug-vs-prod-5f7561db3a59 (future note for myself (ever searched for a solution to a problem and find an old post with the answer - still undecided if it is embarrassing or an example of impressive forethought))

FYI - looks like --reload and --debug are equivalent currently in uvicorn. I'll make a note of that as well.

@tiangolo
Copy link
Owner

tiangolo commented Mar 7, 2019

Thanks! And great post!

In Uvicorn, --debug was the "standard" up to 0.5.0, now it will be --reload, it's very recent.

Check: fastapi/fastapi#66

@ermarkar
Copy link

I have tried

uvicorn.run(self.app, host=host, port=port, debug=True)

and this

uvicorn.run(self.app, host=host, port=port, reload=True)

not working in VSCode

@mironnn
Copy link

mironnn commented Aug 16, 2022

Can reloading be working without a gunicorn?

@wshayes
Copy link
Author

wshayes commented Aug 17, 2022

Can reloading be working without a gunicorn?

Not easily without either uvicorn or gunicorn. It's possible to replicate reload without it, but you still need an ASGI server to run FastAPI anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants