feat(update): update the backend like nodes via quadlet restart [CI]
This commit is contained in:
1 parent
34190f5a04
commit
68c7113adf
23 files changed
+309
-357
No files matched your search
@@ -5,7 +5,7 @@ import type { BackendUpdateDto } from '@shared/api/types'
|
||||
import { Confirm, ErrorNotice, useAction } from '@shared/ui'
|
||||
import { useAuth } from './auth'
|
||||
|
||||
/** webhook 发布后显示当前通道的更新;宿主机验签完成且用户确认同一个 seq 后才升级。 */
|
||||
/** webhook 发布后显示当前通道的更新;用户确认同一个 seq 后,Backend 先备份数据库再退出,由 Quadlet 拉最新镜像重启(和 Agent、Probe 一样)。 */
|
||||
export function BackendUpdateNotice() {
|
||||
const { me } = useAuth()
|
||||
const [update, setUpdate] = useState<BackendUpdateDto>()
|
||||
@@ -32,19 +32,14 @@ export function BackendUpdateNotice() {
|
||||
useEffect(() => {
|
||||
if (!requested || !update) return
|
||||
if (update.state === 'up_to_date' || (update.current_tag && update.current_tag !== originalTag.current)) location.reload()
|
||||
else if (['failed', 'rolled_back', 'invalid'].includes(update.state) || (update.state === 'available' && update.error)) setRequested(false)
|
||||
}, [update, requested])
|
||||
|
||||
if (!update || (!update.available && !requested && update.state !== 'applying')) return null
|
||||
const waiting = requested || update.state === 'requested' || update.state === 'applying'
|
||||
const waiting = requested || update.state === 'applying'
|
||||
const canUpdate = update.enabled && update.state === 'available' && update.available
|
||||
const message = update.state === 'applying' ? 'Backend 正在升级重启,连接恢复后会自动刷新。'
|
||||
: waiting ? '已确认 Backend 更新,正在等待宿主机更新器执行。'
|
||||
: update.state === 'checking' ? '新版本已发布,正在等待宿主机验签。'
|
||||
: !update.enabled ? '新版本已发布,需要在宿主机安装 Backend 更新器。'
|
||||
: update.state === 'invalid' ? '发布清单未通过更新器校验。'
|
||||
: update.state === 'rolled_back' ? '更新失败,已回滚。'
|
||||
: update.state === 'failed' ? '更新失败。' : 'Backend 有新版本。'
|
||||
const message = waiting ? '已确认 Backend 更新,正在备份数据并重启,连接恢复后会自动刷新。'
|
||||
: !update.enabled ? '新版本已发布,但这个 Backend 没有启用重启式更新(需要环境变量 MOSHIRO_UPDATE=restart,Quadlet 模板里已写好)。'
|
||||
: 'Backend 有新版本。'
|
||||
|
||||
return (
|
||||
<div className="notice" style={{ marginBottom: 16 }}>
|
||||
@@ -66,7 +61,7 @@ export function BackendUpdateNotice() {
|
||||
setRequested(true)
|
||||
}
|
||||
}}>
|
||||
将从 {update.current_tag || '当前版本'} 升级到 {confirming.available.tag}({confirming.channel})。宿主机会先备份数据,再升级并重启,期间面板会短暂断开;恢复后自动刷新。如果发布清单已变化,需要重新确认。
|
||||
将从 {update.current_tag || '当前版本'} 升级到 {confirming.available.tag}({confirming.channel})。Backend 会先备份数据库(数据目录下的 backups/),再退出,由 systemd 拉取最新镜像重新启动,期间面板会断开一两分钟,所有节点也会短暂断连;恢复后自动刷新。如果发布清单已变化,需要重新确认。
|
||||
</Confirm>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user