From f99b8a6d2ec0fc2414b939c3fef4d9338d13fce4 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期三, 12 二月 2025 14:07:07 +0800 Subject: [PATCH] 调整场所分析身份条件 --- cron/cron.go | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cron/cron.go b/cron/cron.go index b77c86e..e5a6c31 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,18 +22,25 @@ 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 { + logger.Warnf("Init task %s. %s", t.Name, err.Error()) return } + + model.KeepAlive() + if err := model.Run(); err != nil { + logger.Warnf("Run task %s. %s", t.Name, err.Error()) return } if err := model.Shutdown(); err != nil { @@ -42,7 +51,7 @@ } func Run() (err error) { - _, err = s.Every(1).Minute().StartImmediately().Do(Dispatch) + _, err = s.Every(3).Minute().StartImmediately().Do(Dispatch) if err != nil { return err } -- Gitblit v1.8.0