diff --git a/unilabos/devices/workstation/bioyond_studio/bioyond_cell/bioyond_cell_workstation.py b/unilabos/devices/workstation/bioyond_studio/bioyond_cell/bioyond_cell_workstation.py index 78b635ce..ef4004e3 100644 --- a/unilabos/devices/workstation/bioyond_studio/bioyond_cell/bioyond_cell_workstation.py +++ b/unilabos/devices/workstation/bioyond_studio/bioyond_cell/bioyond_cell_workstation.py @@ -10,6 +10,7 @@ from datetime import datetime, timedelta import re import threading import os +import socket from urllib3 import response from unilabos.devices.workstation.workstation_base import WorkstationBase @@ -170,12 +171,29 @@ class BioyondCellWorkstation(BioyondWorkstation): self.service.start() self.http_service_started = True logger.info(f"WorkstationHTTPService成功启动: {host}:{port}") + # 启动成功后,上报本机推送地址(3.36) try: - r = self.update_push_ip(host, port) - logger.info(f"更新推送IP结果: {r}") + # 优先使用配置中的 report_ip + report_ip = self.bioyond_config.get("report_ip", "").strip() + + # 如果配置中没有指定 report_ip,且监听地址是 0.0.0.0,则自动检测 + if not report_ip and host in ("0.0.0.0", ""): + # 从 Bioyond 配置中提取服务器地址 + bioyond_server = self.bioyond_config.get("base_url", "") + if bioyond_server: + import urllib.parse + parsed = urllib.parse.urlparse(bioyond_server) + + elif not report_ip: + # 如果没有配置 report_ip,使用监听地址 + report_ip = host + + r = self.update_push_ip(report_ip, port) + logger.info(f"向 Bioyond 报送推送地址: {report_ip}:{port}, 结果: {r}") except Exception as e: logger.warning(f"调用更新推送IP接口失败: {e}") + #一直挂着,直到进程退出 while True: time.sleep(1) diff --git a/unilabos/devices/workstation/bioyond_studio/config.py b/unilabos/devices/workstation/bioyond_studio/config.py index c73abd35..e2506bc6 100644 --- a/unilabos/devices/workstation/bioyond_studio/config.py +++ b/unilabos/devices/workstation/bioyond_studio/config.py @@ -23,8 +23,9 @@ BIOYOND_FULL_CONFIG = { "report_token": os.getenv("BIOYOND_REPORT_TOKEN", "CHANGE_ME_TOKEN"), # HTTP 服务配置 - "HTTP_host": os.getenv("BIOYOND_HTTP_HOST", "0.0.0.0"), # 0.0.0.0 绑定所有网络接口 + "HTTP_host": os.getenv("BIOYOND_HTTP_HOST", "0.0.0.0"), # HTTP服务监听地址(0.0.0.0 表示监听所有网络接口) "HTTP_port": int(os.getenv("BIOYOND_HTTP_PORT", "8080")), + "report_ip": os.getenv("BIOYOND_REPORT_IP", "172.21.33.141"), # 报送给 Bioyond 的本机IP地址(留空则自动检测) # 调试模式 "debug_mode": os.getenv("BIOYOND_DEBUG_MODE", "False").lower() == "true",