Skip to content

refactor: 统一使用 gateway run 模式,移除 systemd 单例限制#622

Open
IT-SDJ wants to merge 2 commits into
EKKOLearnAI:mainfrom
IT-SDJ:pr/refactor-gateway-run
Open

refactor: 统一使用 gateway run 模式,移除 systemd 单例限制#622
IT-SDJ wants to merge 2 commits into
EKKOLearnAI:mainfrom
IT-SDJ:pr/refactor-gateway-run

Conversation

@IT-SDJ
Copy link
Copy Markdown

@IT-SDJ IT-SDJ commented May 11, 2026

背景

原来 Web UI 启动 Profile 网关时,会根据环境检测 init 系统(systemd/launchd)决定使用 gateway start 还是 gateway run。但 gateway start 走的是 systemd 单例服务,多个 Profile 无法
并行启动,且 WSL/Docker 等环境不支持 systemd,行为不统一。

变更内容

  • 移除 needsRunMode 检测逻辑,所有环境统一使用 gateway run detached 子进程启动
  • 移除 --replace 参数,改用 gateway run --replace(第二次提交补充)
  • stop() 直接 kill 进程组,不再走 gateway stop 命令
  • 移除所有因 needsRunMode 恒为 true 导致的死代码分支和过时注释
  • 增加 stderr 捕获和 settleOnce 机制,避免 exit 事件与 waitForReady 竞争导致启动失败误判

效果

  • 多个 Profile 的网关可以独立并行运行互不干扰
  • 所有环境(Linux/macOS/WSL/Docker)行为一致
  • 启动失败时日志更清晰(捕获 stderr 输出)

Dev added 2 commits May 11, 2026 09:01
根据多 Gateway 并行启动 CLI 测试结果的后续方向进行重构:

- 移除 initSystem 检测逻辑,needsRunMode 始终为 true
- start() 直接使用 spawn('gateway', ['run']) 启动 detached 子进程
- 移除 --replace 参数
- stop() 直接 kill 进程组,不再走 gateway stop 命令
- 移除所有因 needsRunMode 恒为 true 导致的死代码分支
- 清理过时注释

此变更使多个 Profile 的网关可以独立并行运行互不干扰
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