Skip to content

feat(actions): 强制终止实例(kill)+ 停止是异步的 - #2

Merged
wangzhizhou merged 1 commit into
mainfrom
feat/kill-instance
Oct 28, 2026
Merged

wangzhizhou merged 1 commit into
mainfrom
feat/kill-instance

Conversation

@wangzhizhou

Copy link
Copy Markdown
Contributor

面板的「停止」是异步的:/stop 立即返回 200,实例随后进 STOPPING,服务器读完档才退出。存档很大 / 插件死锁 / JVM 假死时会一直停在 STOPPING —— 那时唯一的出路是强杀,而本包之前没封装(spec 里甚至写着"本包未封装")。

新增

GET /api/protected_instance/kill(operationId killInstance):

  • 官方 apidoc 已收录(api_instance.md 的 GET /api/protected_instance/kill)→ check-apidoc-drift.sh 输出 [ok],不进白名单;
  • 面板 router.all + 前端用 GET;内部转发守护进程 instance/kill → execPreset("kill"),面板超时 INSTANCE_KILL_TIMEOUT = 30000(30 秒,比其它动作长);
  • 权限与其它 protected_instance 端点一致:普通用户也能调。

spec 同步修正

  • /stop 描述原来写「要强制杀进程用 kill(本包未封装)」→ 已封装,并补上「停止是异步的,可能长时间停在 STOPPING」;
  • /kill 的 200 不声明响应体:面板回 {status,data,time} 外壳,data 各版本不一致(10.18.0 是 {instanceUuid}),声明具体 schema 会解码失败(踩过 typeMismatch String/dictionary)。只关心有没有被拒绝(403/500)。

坑

YAML 描述含 { … } 必须加引号 —— 否则被当 flow mapping,生成器报 mapping values are not allowed in this context。

验证

swift test:21 + 20 绿;lifecycleActionsCarryDaemonAndInstance 覆盖 open/stop/restart/kill 的路径与查询参数;scripts/check-apidoc-drift.sh 全 [ok]。

面板的「停止」是**异步**的:`/stop` 立即返回 200,实例随后进 `STOPPING`,服务器读完档才退出。
存档很大 / 插件死锁 / JVM 假死时会一直停在 `STOPPING` —— 那时唯一的出路是强杀,而本包之前没封装。

新增 `GET /api/protected_instance/kill`(operationId `killInstance`):

- 官方 apidoc 已收录(`api_instance.md` 的 `GET /api/protected_instance/kill`),
  `check-apidoc-drift.sh` 是 `[ok]`,不需要进白名单;
- 面板侧 `router.all` + 前端用 GET;内部转发守护进程 `instance/kill` → `execPreset("kill")`,
  面板超时 `INSTANCE_KILL_TIMEOUT = 30000`(30 秒,比其它动作长);
- 权限与其它 `protected_instance` 端点一致:**普通用户也能调**(只要实例属于你)。

两处 spec 说明同步修正:

- `/stop` 的描述原来写「要强制杀进程用 `kill`(本包未封装)」→ 现在已封装,并补上
  「停止是异步的,可能长时间停在 `STOPPING`」这个关键事实;
- `/kill` 的 200 **不声明响应体**:面板回的是 `{status,data,time}` 外壳,`data` 结构各版本不一致
  (10.18.0 实测是 `{instanceUuid}`),声明具体 schema 会因多/少字段解码失败
  (踩过:`typeMismatch String/dictionary`)。我们只关心"有没有被拒绝"(403/500)。

顺带:YAML 描述里含 `{ … }` 必须加引号,否则被当成 flow mapping,`openapi-generator` 直接报
`mapping values are not allowed in this context`。

测试:`lifecycleActionsCarryDaemonAndInstance` 覆盖 open/stop/restart/**kill** 的路径与查询参数。
@wangzhizhou
wangzhizhou merged commit 061866f into main Oct 28, 2026
2 checks passed
@wangzhizhou
wangzhizhou deleted the feat/kill-instance branch October 28, 2026 05:25
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