Skip to content

fix: 修复 Windows 下 Gateway 运行态误判导致重复拉起#173

Open
g1621146262-netizen wants to merge 2 commits intoqingchencloud:mainfrom
g1621146262-netizen:fix/windows-gateway-running-detect
Open

fix: 修复 Windows 下 Gateway 运行态误判导致重复拉起#173
g1621146262-netizen wants to merge 2 commits intoqingchencloud:mainfrom
g1621146262-netizen:fix/windows-gateway-running-detect

Conversation

@g1621146262-netizen
Copy link
Copy Markdown

fix: 修复 Windows 下 Gateway 运行态误判导致重复拉起

问题描述

在 Windows 环境下,Gateway 状态检测逻辑会将“通过端口识别到 PID”作为运行态判断条件之一。
当 Gateway 实际已监听端口,但 PID 识别偶发失败时,会被误判为未运行,触发守护重复拉起,导致:

  • 日志反复出现重复启动行为
  • 端口冲突(18789 已被占用)
  • 会话连接抖动(用户体感为“做一下停一下”)

修复方案

调整 Windows 平台 check_service_status 逻辑:

  • 端口可达时,直接判定 Gateway 处于运行态
  • PID 识别仅作为增强信息(可选),不再作为运行态必要条件

即:当端口已通但未识别到 PID 时,返回 (true, None),避免误判为停止。

具体改动

  • 文件:src-tauri/src/commands/service.rs
  • 函数:Windows check_service_status(...)
  • 关键变化:
    • 旧逻辑:端口通但 PID 获取失败 => (false, None)
    • 新逻辑:端口通但 PID 获取失败 => (true, None)

影响范围

  • 平台:Windows
  • 模块:Gateway 服务状态检测 / 守护重启策略
  • 用户可见效果:
    • 减少错误重启
    • 减少端口冲突与连接抖动
    • 改善长任务连续执行稳定性

测试建议

  1. 启动 Gateway 后观察日志,确认不再重复触发 hidden-start。
  2. 验证服务状态在 UI 中稳定显示为运行,不再反复抖动。
  3. 人工停止 Gateway 后,守护仍可按预期拉起(正常场景不受影响)。
  4. 执行连续任务,验证不再出现“做一下停一下”的中断体验。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant