1、波段触发修改

This commit is contained in:
2025-04-21 17:32:57 +08:00
parent 79af1ab2c1
commit 44ba8bfbf1
11 changed files with 314 additions and 71 deletions

View File

@ -3,6 +3,7 @@ package jobs
import (
"fmt"
models2 "go-admin/app/jobs/models"
"runtime"
"time"
log "github.com/go-admin-team/go-admin-core/logger"
@ -43,7 +44,10 @@ type ExecJob struct {
func (e *ExecJob) Run() {
defer func() {
if err := recover(); err != nil {
log.Errorf("脚本任务失败:%v", err)
// 获取调用栈信息
buf := make([]byte, 1<<16) // 64KB 缓冲区
n := runtime.Stack(buf, false)
log.Errorf("脚本任务失败: %v\n%s", err, buf[:n])
}
}()

View File

@ -0,0 +1,22 @@
package jobs
import (
"go-admin/common/helper"
"testing"
"github.com/go-admin-team/go-admin-core/sdk"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
func TestStrategyJob(t *testing.T) {
dsn := "root:123456@tcp(127.0.0.1:3306)/go_exchange_single?charset=utf8mb4&parseTime=True&loc=Local&timeout=1000ms"
db, _ := gorm.Open(mysql.Open(dsn), &gorm.Config{})
sdk.Runtime.SetDb("default", db)
helper.InitDefaultRedis("127.0.0.1:6379", "", 2)
helper.InitLockRedisConn("127.0.0.1:6379", "", "2")
job := StrategyJob{}
job.Exec([]string{})
}