modify: mqtt uri 支持 AIBOX_MQTT_URI 环境变量兜底

This commit is contained in:
2026-08-14 16:27:31 +08:00
parent 4fa066432d
commit f723a8441b
+5 -2
View File
@@ -13,6 +13,7 @@ AI Box Sophon Adapter — MQTT 客户端能力组件
"Worker ... 无回复,尝试重试"。
"""
import logging
import os
from typing import Any
logger = logging.getLogger(__name__)
@@ -135,7 +136,8 @@ async def start_mqtt_forward(cfg: dict) -> Any:
from chongming_mqtt.mqtt_forward import MQTTForwardClient
uri = cfg.get("uri", "")
# uri 含凭据,优先配置;留空时从环境变量 AIBOX_MQTT_URI 兜底(避免凭据入库)
uri = cfg.get("uri") or os.environ.get("AIBOX_MQTT_URI", "")
topic = cfg.get("topic", "/board_ping")
logger.warning(
"[MQTTForward] 配置已加载: enabled=%s, uri=%s, topic=%s", enabled, uri, topic
@@ -162,7 +164,8 @@ async def start_mqtt_subscribe(cfg: dict) -> Any:
from chongming_mqtt.mqtt_subscribe import MQTTSubscribeClient
uri = cfg.get("uri", "")
# uri 含凭据,优先配置;留空时从环境变量 AIBOX_MQTT_URI 兜底(避免凭据入库)
uri = cfg.get("uri") or os.environ.get("AIBOX_MQTT_URI", "")
topics = cfg.get("topics", []) or []
logger.warning(
"[MQTTSubscribe] 配置已加载: enabled=%s, uri=%s, topics=%s",