configuration.md
docs
configuration.md
⚙️ Advanced Configuration Guide
Asteri is designed for ultimate flexibility. Whether you prefer quick CLI flags, environment-specific variables, or professional Python-based configuration files, Asteri gives you total control over your server environment.
Configuration Hierarchy
When settings are defined in multiple places, Asteri follows this priority (highest to lowest):
- Command Line Arguments (overrides everything)
- Environment Variables
- Configuration File
- 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"