question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

File-based configuration

See original GitHub issue

Hi 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:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
maquino1985commented, Aug 16, 2022

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

0reactions
florimondmancacommented, Dec 12, 2020

I’ll close this, since I’ve actually been able to do without this very well since I posted this issue. 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found