dockerfiles added
This commit is contained in:
@@ -104,10 +104,12 @@ def load_devices() -> list[dict[str, Any]]:
|
||||
def get_mqtt_settings() -> tuple[str, int]:
|
||||
"""Get MQTT broker settings from environment.
|
||||
|
||||
Supports both MQTT_BROKER and MQTT_HOST for compatibility.
|
||||
|
||||
Returns:
|
||||
tuple: (host, port)
|
||||
"""
|
||||
host = os.environ.get("MQTT_HOST", "172.16.2.16")
|
||||
host = os.environ.get("MQTT_BROKER") or os.environ.get("MQTT_HOST", "172.16.2.16")
|
||||
port = int(os.environ.get("MQTT_PORT", "1883"))
|
||||
return host, port
|
||||
|
||||
@@ -115,9 +117,24 @@ def get_mqtt_settings() -> tuple[str, int]:
|
||||
def get_redis_settings() -> tuple[str, str]:
|
||||
"""Get Redis settings from configuration.
|
||||
|
||||
Prioritizes environment variables over config file:
|
||||
- REDIS_HOST, REDIS_PORT, REDIS_DB → redis://host:port/db
|
||||
- REDIS_CHANNEL → pub/sub channel name
|
||||
|
||||
Returns:
|
||||
tuple: (url, channel)
|
||||
"""
|
||||
# Check environment variables first
|
||||
redis_host = os.getenv("REDIS_HOST")
|
||||
redis_port = os.getenv("REDIS_PORT", "6379")
|
||||
redis_db = os.getenv("REDIS_DB", "0")
|
||||
redis_channel = os.getenv("REDIS_CHANNEL", "ui:updates")
|
||||
|
||||
if redis_host:
|
||||
url = f"redis://{redis_host}:{redis_port}/{redis_db}"
|
||||
return url, redis_channel
|
||||
|
||||
# Fallback to config file
|
||||
config_path = Path(__file__).parent.parent.parent / "config" / "devices.yaml"
|
||||
|
||||
if config_path.exists():
|
||||
|
||||
Reference in New Issue
Block a user