-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Restart workers when code changes in development mode #31
Comments
From my experience it's kind of a pain to use reloading with the WSGI + ASGI combo, so for development I usually go with pure uvicorn and just mount the volume. It's worked fine so far |
@jeanlst I agree. This approach would be much easier to implement and less buggy. I'm having difficulties deciding on the way in which this feature should be implemented. For now, I have thought of:
I personally lean towards solution number 3. |
@rszamszur I worked a little more with fastapi-mvc and put on github another example of using it with logs via Loguru, working with Gunicorn/Uvicorn, without any log problem with log rotation in Gunicorn with multiple Workers. I didn't change anything in wsgi.py and used --config to specify the Gunicorn configuration file specific to Loguru. For development I use Uvicorn and run it via this configuration in pyproject.toml: mvc-demo-dev = 'mvc_demo.wsgi_uvicorn:run_dev_wsgi' The repository is this: https://github.com/abnerjacobsen/fastapi-mvc-loguru-demo His readme explains what I did. I agree with @jeanlst , hot reloading with Gunicorn is almost impossible, not worth spending time on. And I also agree with your idea of implementing a development mode to fastapi-mvc and, thus, instead of it being a template generator from the cookiecutter, it becomes a deployment generator/tester for environments like Kubernetes, docker-compose or serverless (I personally use the AWS Lambda solution a lot). |
@abnerjacobsen, @jeanlst, thanks for the input, I really appreciate it. At the moment I'm working on adding the documentation and development server. After that, I'll jump into the topic of logging with loguru. |
@abnerjacobsen that looks great, thanks for the repo using loguru! I'm a bit on the boat of using the standard logging lib instead of loguru tho. Maybe I'll stop being stubborn and use loguru but that's unlikely |
@abnerjacobsen I've used your piece of code for running uvicorn programmatically, works like charm! |
It would be useful to have reloading changes in development mode. Either as a new option
--reload
to template CLI serve command, or automatically based on env variable, ex:FASTAPI_ENV=development FASTAPI_ENV=production
, similar to Ruby on Rails. Not yet sure which approach would be better. Moreover, just adding--reload
flag to WSGI + ASGI combo doesn't work properly, at least from initial tests. It's possible that for development in order to have reloading changes app would need to run on pure uvicorn (ASGI).TODO:
The text was updated successfully, but these errors were encountered: