configuration.md
docs
configuration.md
⚙️ Configuration
Asteri offers a flexible configuration system that allows you to manage settings via CLI arguments, environment variables, or a dedicated Python configuration file.
Configuration Hierarchy
When settings are defined in multiple places, Asteri follows this priority (highest to lowest): 1. Command Line Arguments (overrides everything) 2. Environment Variables 3. Configuration File 4. Default Values
The Configuration File
Using a Python configuration file is the most "professional" way to manage complex application settings. It allows for dynamic logic and clear organization.
📝 Comprehensive Example (asteri.conf.py)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
Running with Configuration
To start Asteri using a configuration file, use the -c or --config flag:
1 | |
💡 Tips for Config Files
- Lists for Bindings: Always use a list for the
bindvariable if you want to listen on multiple ports. - Python Logic: Since the config file is a Python script, you can use logic to determine settings based on environment:
python import os workers = os.cpu_count() * 2 + 1 debug = os.getenv("DEBUG") == "True" log_level = "debug" if debug else "info"