Feat/gateway starter - #1776
Open
Nexisato wants to merge 15 commits into
Open
Feat/gateway starter#1776Nexisato wants to merge 15 commits into
Nexisato wants to merge 15 commits into
Conversation
SAKURA-CAT
force-pushed
the
feature/core
branch
from
September 22, 2026 08:01
2d33d99 to
e2d1da0
Compare
Nexisato
force-pushed
the
feat/gateway-starter
branch
from
September 22, 2026 08:25
5d35dc1 to
c933966
Compare
Nexisato
marked this pull request as ready for review
September 23, 2026 07:16
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.
概述
实现 swanlab-core(Go)的进程启动与生命周期框架(Owner Mode):
功能点
启动与端点回报
Python SDK 通过
subprocess.Popen启动swanlab-core。未指定--listen时按平台自选端点:POSIX 使用 runtime 目录内的 UDS,listen 失败记录 warning 后回退127.0.0.1:0;Windows 使用回环 TCP。listen 与 gRPC server 初始化成功后原子写入 port-file(同目录临时文件 + chmod 0600 + rename),Python 轮询该文件完成握手。显式--listen视为调用方指定端点,失败报错;tcp://限定回环地址。port-file 为最小协议,承担临时 endpoint discovery,不携带鉴权或身份字段:
信任模型
POSIX 使用 UDS(socket 文件位于 owner-only 私有 runtime 目录),port-file 以 0600 权限发布;loopback TCP 回退不隔离本机用户,能连接端口的本机进程可调用全部 RPC。
生命周期与 run 路由
NOT_READY → READY → STOPPING → CLOSED:SpinupService幂等置 READY,READY 前 run 级 RPC 返回FAILED_PRECONDITION;DeliverRunStart创建随机run_handle存入并发安全 registry,run 级 RPC 按 handle 路由;ConfirmRunFinish在对应 run 的DeliverRunFinish交付后原子释放 session(提前调用返回FAILED_PRECONDITION,会话保留),不关闭 gRPC Server;TeardownService在独立 goroutine 执行 GracefulStop,避免 handler 内自等待;pid字段判定归属,路径被后启动实例覆盖时不误删。父进程监控
Linux 使用 PDEATHSIG 快路径,另有进程级兜底:先使用 pidfd,不可用时低频轮询 PID/PPID,覆盖从非主线程 spawn、spawn 线程先退出的场景;监控通知 controller,不在监控 goroutine 中执行关闭。
detached 预留
--detach与--idle-timeout为 detached 模式预留,当前版本接受传值但作为 no-op 忽略并记录 warning,core 仍以 Owner Mode 运行,当前实现暂不添加 detached 运行逻辑。协议调整
core.proto新增 Spinup/Teardown RPC;DeliverRunStart响应返回run_handle,upsert/finish/stats/confirm 等 run 级请求携带该 handle;Python/Go stub 重新生成。启动流程
风险提示
升级后的发行版暂不支持 alpine 镜像,rpc 通信需要依赖标准的
grpcio库,要求基础镜像中必须携带 glibc 库,与 numpy 保留同级环境要求