From 196b0d0b5ee6ebeee11112bb513c77b99132271d Mon Sep 17 00:00:00 2001 From: qian Date: Sat, 15 Aug 2026 00:30:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(update):=E4=BF=AE=E5=A4=8D=E5=9B=9E?= =?UTF-8?q?=E6=BB=9A=E6=93=8D=E4=BD=9C=E6=9C=AA=E7=AD=89=E5=BE=85=E5=B0=B1?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E9=80=80=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/logic/update/rollback.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/logic/update/rollback.go b/internal/logic/update/rollback.go index 77b0332..9d02850 100644 --- a/internal/logic/update/rollback.go +++ b/internal/logic/update/rollback.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "path/filepath" + "time" "github.com/gogf/gf/v2/frame/g" @@ -67,10 +68,15 @@ func Rollback(ctx context.Context) error { _ = os.Remove(filepath.Join(updateDir, pendingVerificationFile)) _ = os.Remove(oldPath) - g.Log().Infof(ctx, "Rollback to %s complete, exiting for restart...", info.BackupVersion) + g.Log().Infof(ctx, "Rollback to %s complete, scheduling restart...", info.BackupVersion) - // Exit — process supervisor will restart with the old binary - os.Exit(0) + // 延迟退出:Rollback 在 HTTP handler 调用栈内同步执行,直接 os.Exit 会切断 + // 尚未写出的响应(前端拿到连接重置而非成功提示)。先让 handler 返回响应, + // 稍后退出进程,由进程管理器(systemd/supervisor 等)拉起旧版本 + go func() { + time.Sleep(500 * time.Millisecond) + os.Exit(0) + }() return nil }