可靠性: 完善 R2 备份恢复与对象生命周期

This commit is contained in:
tamakyi
2026-11-05 08:41:55 +08:00
parent 3e7719f200
commit 937e688cfa
32 changed files with 4151 additions and 231 deletions
+10 -1
View File
@@ -10,6 +10,7 @@ import (
"net/http"
"os"
"os/signal"
"sync"
"syscall"
"time"
@@ -209,7 +210,15 @@ func runWeb(ctx *cli.Context) error {
// 「提问已 INSERT、图片还没传完」「回答已写入、配额还没扣」这类半成品。
// systemd Restart=always 与 docker restart 都救不了这个。
runCtx, stop := signal.NotifyContext(ctx.Context, syscall.SIGTERM, os.Interrupt)
defer stop()
var r2WorkerWG sync.WaitGroup
defer func() {
// 先取消 worker 的 context,再等待当前一轮退出,避免无人等待的后台删除。
stop()
r2WorkerWG.Wait()
}()
// db.Init 已成功;R2 未完整配置时此函数直接返回,不影响 Web 启动。
startR2OutboxWorker(runCtx, &r2WorkerWG)
serveErr := make(chan error, 1)
go func() {