From 9c4d0256cf8abb179a9f0d7f1e7cd526f6497359 Mon Sep 17 00:00:00 2001 From: calvincao Date: Wed, 22 Oct 2025 16:38:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E6=96=B0=E5=A2=9E=20report=5Fip=20=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E4=BB=A5=E6=94=AF=E6=8C=81=E6=9C=AC=E6=9C=BA=20IP=20?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E7=9A=84=E7=81=B5=E6=B4=BB=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=9B=E5=9C=A8=20bioyond=5Fcell=5Fworkstation.py=20?= =?UTF-8?q?=E4=B8=AD=E4=BC=98=E5=8C=96=E6=8E=A8=E9=80=81=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=80=BB=E8=BE=91=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=A3=80=E6=B5=8B=E5=92=8C=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=BC=98=E5=85=88=E7=BA=A7=E5=A4=84=E7=90=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bioyond_cell/bioyond_cell_workstation.py | 22 +++++++++++++++++-- .../workstation/bioyond_studio/config.py | 3 ++- 2 files changed, 22 insertions(+), 3 deletions(-) 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",