Refactor start script to improve organization of Gunicorn and Uvicorn server settings #30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The core logic for running the Uvicorn and Gunicorn+Uvicorn servers is located in start.py. The
start.start_server()
method is what actually starts the servers. Gunicorn and Uvicorn are configured differently, so thestart.start_server()
method ended up getting quite complex in order to handle these differences.This PR will refactor the configuration options passed to Gunicorn and Uvicorn into separate functions. The result is a start script with the same programming API and almost exactly the same line length, but improved readability and separation of concerns.
Changes
start.set_gunicorn_options()
andstart.set_uvicorn_options()
.start.set_conf_path()
: this function was written in a general way to find either Gunicorn or logging configuration files. Starting with ff9155a, it became used only for Gunicorn configuration files. Now that the configuration options for Gunicorn are in a separate function, the logic fromset_conf_path()
can be moved there.import logging
and annotate logger objects passed in as function arguments withlogging.Logger
instead of having a separate import forfrom logging import Logger
.Related
#2
#3
ff9155a