refactor: 统一使用 gateway run 模式,移除 systemd 单例限制#622
Open
IT-SDJ wants to merge 2 commits into
Open
Conversation
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 的网关可以独立并行运行互不干扰
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
原来 Web UI 启动 Profile 网关时,会根据环境检测 init 系统(systemd/launchd)决定使用
gateway start还是gateway run。但gateway start走的是 systemd 单例服务,多个 Profile 无法并行启动,且 WSL/Docker 等环境不支持 systemd,行为不统一。
变更内容
needsRunMode检测逻辑,所有环境统一使用gateway rundetached 子进程启动--replace参数,改用gateway run --replace(第二次提交补充)stop()直接 kill 进程组,不再走gateway stop命令needsRunMode恒为 true 导致的死代码分支和过时注释settleOnce机制,避免 exit 事件与 waitForReady 竞争导致启动失败误判效果