mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-11-23 04:41:41 +01:00
fix(update): switch versions without interrupting sign-in
This commit is contained in:
1 parent
f3997c48eb
commit
5d98f5d805
23 files changed
+463
-241
No files matched your search
@@ -153,7 +153,7 @@ match the files on disk, recovery refuses to overwrite them.
|
||||
### Switching to the new binary
|
||||
|
||||
On macOS and Linux, when started from the `cyberstrike-ai` binary alongside its config, the console
|
||||
sends `restart: true` by default. After a successful build and binary swap, the service closes its
|
||||
sends `restart: true` as soon as you click **One-Click Update**. After a successful build and binary swap, the service closes its
|
||||
application resources and executes the new binary with the same PID, arguments, environment and
|
||||
working directory. Installations that cannot switch in place return `400` on an explicit restart
|
||||
request. CLI updates and REST updates without `restart: true` only replace files on disk.
|
||||
@@ -163,11 +163,12 @@ the binary identity captured at startup (size + nanosecond mtime) with what is o
|
||||
update, a rollback or a CLI run swapped the file without a restart, `needsRestart` is true,
|
||||
`binaryBuiltAt` says when it was built, and the console grows a persistent banner with **Restart now**
|
||||
(`POST /api/system/update/restart`; `409 nothing_pending` when there is nothing to activate, `409`
|
||||
while a job runs, `400` when unavailable). The console uses the `autoRestart` field as its default.
|
||||
while a job runs, `400` when unavailable). The console checks `canRestart` before requesting automatic activation.
|
||||
|
||||
**The page reloads automatically.** The console polls the session validation endpoint every two
|
||||
seconds for the new boot marker. Sessions live in memory, so users sign in again after the switch.
|
||||
Leaving the console stops the polling.
|
||||
seconds for the new boot marker. When both versions support session handoff, existing sessions keep
|
||||
their original expiration and permissions are loaded from the current RBAC store. The first upgrade
|
||||
from an older version may still require sign-in. Leaving the console stops the polling.
|
||||
|
||||
## Adding a Business Module
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ Server `POST /api/auth/login` returns `{ token, expires_at }`. There is **no ref
|
||||
| Local check | Re-check `expires_at` + `GET /api/auth/validate` every 30s |
|
||||
| Server probe | Immediate probe when DevTools panel becomes visible |
|
||||
| Unreachable | Show warning; keep token during transient outage |
|
||||
| 401/403 | Clear token (server restart clears in-memory sessions) |
|
||||
| 401/403 | Clear token and require re-authentication |
|
||||
| Before Send | `ensureAuthReady()` before SSE |
|
||||
| Permissions | `optional_host_permissions` — request origin on Validate |
|
||||
|
||||
|
||||
@@ -189,9 +189,9 @@ SQLite 热备份时最好先停止服务,或至少复制 `*.db`、`*.db-wal`
|
||||
并被页面标出,装好 go 后再点一次「一键更新」即补编译。
|
||||
细节见 [开发者指南](developer-guide.md) 的「一键更新」一节。
|
||||
|
||||
在 macOS/Linux 上,从配置文件同目录的 `cyberstrike-ai` 启动时,控制台默认在构建成功后自动切换到新二进制。
|
||||
构建期间旧服务继续提供服务;切换时连接会短暂中断,页面在新服务应答后自动刷新(内存中的登录会话需重新登录)。
|
||||
这一步不依赖 systemd 或 launchd;长期部署仍建议用守护进程做开机自启和异常恢复。取消自动切换、或在命令行换过
|
||||
在 macOS/Linux 上,从配置文件同目录的 `cyberstrike-ai` 启动时,点击「一键更新」后,控制台在构建成功时自动切换到新二进制。
|
||||
构建期间旧服务继续提供服务;切换时连接会短暂中断,页面在新服务应答后自动刷新并沿用仍然有效的登录会话。
|
||||
这一步不依赖 systemd 或 launchd;长期部署仍建议用守护进程做开机自启和异常恢复。通过 API 或命令行换过
|
||||
二进制后,可以在支持自动切换的安装上用控制台的「立即重启服务」启用磁盘上的版本。
|
||||
|
||||
更新源是 `config.yaml` `update` 段里的**一个仓库地址**(`repo`),也可以直接在控制台「一键更新」页填写保存:
|
||||
|
||||
@@ -143,17 +143,17 @@ update:
|
||||
|
||||
### 切换到新二进制
|
||||
|
||||
macOS/Linux 上,从配置文件同目录的 `cyberstrike-ai` 启动时,控制台默认发送 `restart: true`。
|
||||
macOS/Linux 上,从配置文件同目录的 `cyberstrike-ai` 启动时,点击「一键更新」直接发送 `restart: true`,无需二次确认。
|
||||
只有成功构建并换入二进制才会切换:服务先关闭应用资源,再用相同 PID、启动参数、环境和工作目录执行新二进制。
|
||||
不支持的启动方式不提供自动切换;REST 显式请求重启时返回 `400`。REST 不传该字段和 CLI 更新都只换磁盘文件。
|
||||
|
||||
**待生效状态是持久的、可补重启。** 状态接口对比"启动时记下的二进制身份(大小 + 纳秒 mtime)"与磁盘
|
||||
现值:更新、回滚或 CLI 换过二进制而没重启时,`needsRestart` 为真、`binaryBuiltAt` 给出构建时间,
|
||||
控制台顶部出现常驻横幅与「立即重启服务」(`POST /api/system/update/restart`;没有待生效版本时
|
||||
`409 nothing_pending`、有任务在跑 `409`、不支持时 `400`)。控制台根据 `autoRestart` 决定默认值。
|
||||
`409 nothing_pending`、有任务在跑 `409`、不支持时 `400`)。控制台根据 `canRestart` 决定能否自动切换。
|
||||
|
||||
**重启后页面自动刷新。** 控制台每 2 秒通过会话验证接口探测服务启动标记,收到新标记才刷新。
|
||||
现有登录会话保存在内存中,切换后需要重新登录。离开控制台则停止探测。
|
||||
支持会话交接的两个版本之间切换时,有效登录保持原来的到期时间,权限从新进程的 RBAC 存储重新加载。首次从旧版升级时可能需要重新登录。离开控制台则停止探测。
|
||||
|
||||
## 数据库
|
||||
|
||||
|
||||
Reference in new issue
Block a user