File-based configuration
See original GitHub issueHi there,
Has file-based configuration ever been considered for uvicorn? By that, I mean starting the server via a config file which we contain values for any made available by the uvicorn
command.
gunicorn has this feature and I like how the config file is just a plain Python script, which allows to do any sorts of computation (e.g. deriving the number of workers from the number of CPUs). File-based configuration also allows the server config to be version-controlled and written once and for all for a given project.
As an illustration, I imagine that file-based configuration would allow to use:
# config.py
import os
import multiprocessing
host = "0.0.0.0"
port = 5050
workers = 2 * multiprocessing.cpu_count() + 1
log_level = "debug"
reload = not os.environ.get("PRODUCTION")
uvicorn -c config.py app:app
Instead of:
uvicorn --host="0.0.0.0" --port=5050 --workers=4 --log-level=debug --reload app:app
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:6 (5 by maintainers)
Top Results From Across the Web
File-based Configurations - Apache Commons
File -based configurations typically define a set of constructors that correspond to the various setter methods for defining the data file. These ...
Read more >File-based configuration - Netlify Docs
The netlify.toml is a configuration file that specifies how Netlify builds and deploys your site — including redirects, branch and context-specific settings ...
Read more >Introducing Properties File Based Configuration - IBM
This command extracts configuration data to a specified properties file. The command either takes target object or config data specified by -configData ...
Read more >Configuration file - Wikipedia
In computing, configuration files are files used to configure the parameters and initial settings for some computer programs.
Read more >What is configuration file? | Definition from TechTarget
A configuration file, often shortened to config file, defines the parameters, options, settings and preferences applied to operating systems (OSes), ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Would be great if this was reopened and worked on. I think it’s very helpful with my gunicorn apps, not sure how to configure uvicorn at all if its being run from a docker container pointing to an app (e.g. fastapi) and not run explicitly via the backend
I’ll close this, since I’ve actually been able to do without this very well since I posted this issue. 😃