From a25ee90c656b39e652f24e3378ad2bf5698b162b Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期五, 20 十二月 2024 01:59:06 +0800 Subject: [PATCH] 添加疑似托管模型 --- cron/cron.go | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cron/cron.go b/cron/cron.go index b77c86e..f85d719 100644 --- a/cron/cron.go +++ b/cron/cron.go @@ -1,12 +1,14 @@ package cron import ( + "time" + "github.com/go-co-op/gocron" + "model-engine/models" "model-engine/pkg/logger" "model-engine/pkg/safe" "model-engine/service" - "time" ) var s *gocron.Scheduler @@ -20,15 +22,17 @@ if err != nil { panic(err) } + for _, task := range tasks { model, err := models.GetModel(task.ModelID) if err != nil { logger.Errorf("can not find model for id:%v", task.ModelID) continue } - task := task + + t := task safe.Go(func() { - if err := model.Init(task); err != nil { + if err := model.Init(t); err != nil { return } if err := model.Run(); err != nil { @@ -42,7 +46,7 @@ } func Run() (err error) { - _, err = s.Every(1).Minute().StartImmediately().Do(Dispatch) + _, err = s.Every(10).Minute().StartImmediately().Do(Dispatch) if err != nil { return err } -- Gitblit v1.8.0