From d30b9321b298fff37f4595a6e13c1b882d881274 Mon Sep 17 00:00:00 2001 From: CaIon <1808837298@qq.com> Date: Fri, 12 Jan 2024 18:38:45 +0800 Subject: [PATCH] chore: UpdateMidjourneyTaskBulk with SafeGoroutine --- controller/midjourney.go | 6 ------ main.go | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/controller/midjourney.go b/controller/midjourney.go index 3e0faff..e1659d9 100644 --- a/controller/midjourney.go +++ b/controller/midjourney.go @@ -148,12 +148,6 @@ import ( */ func UpdateMidjourneyTaskBulk() { - //revocer - defer func() { - if err := recover(); err != nil { - log.Printf("UpdateMidjourneyTask panic: %v", err) - } - }() //imageModel := "midjourney" ctx := context.TODO() for { diff --git a/main.go b/main.go index 3675d62..19ae54a 100644 --- a/main.go +++ b/main.go @@ -85,7 +85,9 @@ func main() { } go controller.AutomaticallyTestChannels(frequency) } - go controller.UpdateMidjourneyTaskBulk() + common.SafeGoroutine(func() { + controller.UpdateMidjourneyTaskBulk() + }) if os.Getenv("BATCH_UPDATE_ENABLED") == "true" { common.BatchUpdateEnabled = true common.SysLog("batch update enabled with interval " + strconv.Itoa(common.BatchUpdateInterval) + "s")