refactor: Hub二进制改为Docker构建时下载,优化部署流程与worker初始化

- Dockerfile: 移除COPY预编译二进制,改为构建时通过HUB_TAG从GitHub Release下载
- CI: 移除artifact上传/下载步骤,通过build-args传递Hub tag
- deploy.sh: 重构参数解析,支持--hub-tag指定版本,跟踪tag变化触发重建
- build.sh: 新增--image模式支持构建并推送Hub Docker镜像
- hub.rs: worker连接时同步所有节点在线状态,避免状态不一致
- proxy_nodes: 启动时主动建立Hub worker连接,消除懒连接窗口期
- docker-compose.yml: app镜像支持APP_IMAGE环境变量配置
- README: 更新部署文档,推荐本地构建方式
This commit is contained in:
fawney19
2026-03-02 11:24:14 +08:00
parent c9dbe7936b
commit 0564893c4f
12 changed files with 540 additions and 231 deletions

View File

@@ -97,6 +97,19 @@ async def _on_startup() -> None:
config.worker_processes,
)
# Hub 模式下worker 启动时主动建立 /worker 长连接:
# - 立即接收 NODE_STATUS 广播避免“proxy 已连但 UI 仍显示离线”的窗口期
# - 确保后续 tunnel 请求不需要首请求触发懒连接
if hub_enabled:
from src.services.proxy_node.hub_transport import get_hub_connection_manager
try:
await get_hub_connection_manager().ensure_connected()
logger.info("Hub worker channel initialized on startup")
except Exception as e:
# ensure_connected 失败时内部会启动重连循环,这里仅记录告警不阻塞启动
logger.warning("Hub worker channel init failed, reconnecting in background: {}", e)
from src.clients import get_redis_client
redis_client = await get_redis_client()