diff --git a/check_task.go b/check_task.go index 8dcf98e..572dd1d 100644 --- a/check_task.go +++ b/check_task.go @@ -5,7 +5,6 @@ import ( "go.dtapp.net/gojobs/jobs_gorm_model" "go.dtapp.net/gotime" "gorm.io/gorm" - "log" ) // CheckManyTask 多任务检查 @@ -15,11 +14,11 @@ func (c *Client) CheckManyTask(ctx context.Context, tx *gorm.DB, vs []jobs_gorm_ diffInSecondWithAbs := gotime.Current().DiffInSecondWithAbs(gotime.SetCurrent(v.UpdatedAt).Time) if diffInSecondWithAbs >= v.Frequency*3 { if c.config.debug == true { - log.Printf("[jobs.CheckManyTask]每隔%v秒任务:%v相差%v秒\n", v.Frequency, v.Id, diffInSecondWithAbs) + c.zapLog.WithTraceId(ctx).Sugar().Infof("[jobs.CheckManyTask]每隔%v秒任务:%v相差%v秒\n", v.Frequency, v.Id, diffInSecondWithAbs) } err := tx.Where("task_id = ?", v.Id).Where("run_id = ?", v.RunId).Delete(&jobs_gorm_model.TaskLogRun{}).Error if err != nil { - log.Println("删除失败", err.Error()) + c.zapLog.WithTraceId(ctx).Sugar().Errorf("删除失败:%s", err.Error()) } } } @@ -31,11 +30,11 @@ func (c *Client) CheckSingleTask(ctx context.Context, tx *gorm.DB, v jobs_gorm_m diffInSecondWithAbs := gotime.Current().DiffInSecondWithAbs(gotime.SetCurrent(v.UpdatedAt).Time) if diffInSecondWithAbs >= v.Frequency*3 { if c.config.debug == true { - log.Printf("[jobs.CheckManyTask]每隔%v秒任务:%v相差%v秒\n", v.Frequency, v.Id, diffInSecondWithAbs) + c.zapLog.WithTraceId(ctx).Sugar().Infof("[jobs.CheckManyTask]每隔%v秒任务:%v相差%v秒\n", v.Frequency, v.Id, diffInSecondWithAbs) } err := tx.Where("task_id = ?", v.Id).Where("run_id = ?", v.RunId).Delete(&jobs_gorm_model.TaskLogRun{}).Error if err != nil { - log.Println("删除失败", err.Error()) + c.zapLog.WithTraceId(ctx).Sugar().Errorf("删除失败:%s", err.Error()) } } } diff --git a/const.go b/const.go index 95a3678..6f6a61e 100644 --- a/const.go +++ b/const.go @@ -1,6 +1,6 @@ package gojobs const ( - Version = "1.0.74" + Version = "1.0.75" SpecifyIpNull = "0.0.0.0" ) diff --git a/jobs_gorm_model/task_log_run.go b/jobs_gorm_model/task_log_run.go index b07293d..8a4cab2 100644 --- a/jobs_gorm_model/task_log_run.go +++ b/jobs_gorm_model/task_log_run.go @@ -13,6 +13,7 @@ type TaskLogRun struct { Arch string `gorm:"comment:系统架构" json:"arch"` // 系统架构 Gomaxprocs int `gorm:"comment:CPU核数" json:"gomaxprocs"` // CPU核数 GoVersion string `gorm:"comment:GO版本" json:"go_version"` // GO版本 + SdkVersion string `gorm:"comment:SDK版本" json:"sdk_version"` // SDK版本 MacAddrs string `gorm:"comment:Mac地址" json:"mac_addrs"` // Mac地址 CreatedAt time.Time `gorm:"autoCreateTime;comment:创建时间" json:"created_at"` // 创建时间 } diff --git a/jobs_mongo_model/task_log_run.go b/jobs_mongo_model/task_log_run.go index 4064530..4924693 100644 --- a/jobs_mongo_model/task_log_run.go +++ b/jobs_mongo_model/task_log_run.go @@ -6,17 +6,18 @@ import ( // TaskLogRun 任务执行日志模型 type TaskLogRun struct { - Id primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` // 记录编号 - TaskId uint `json:"task_id,omitempty" bson:"task_id,omitempty"` // 任务编号 - RunId string `json:"run_id,omitempty" bson:"run_id,omitempty"` // 执行编号 - OutsideIp string `json:"outside_ip,omitempty" bson:"outside_ip,omitempty"` // 外网ip - InsideIp string `json:"inside_ip,omitempty" bson:"inside_ip,omitempty"` // 内网ip - Os string `json:"os,omitempty" bson:"os,omitempty"` // 系统类型 - Arch string `json:"arch,omitempty" bson:"arch,omitempty"` // 系统架构 - Gomaxprocs int `json:"gomaxprocs,omitempty" bson:"gomaxprocs,omitempty"` // CPU核数 - GoVersion string `json:"go_version,omitempty" bson:"go_version,omitempty"` // GO版本 - MacAddrs string `json:"mac_addrs,omitempty" bson:"mac_addrs,omitempty"` // Mac地址 - CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty"` // 创建时间 + Id primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` // 记录编号 + TaskId uint `json:"task_id,omitempty" bson:"task_id,omitempty"` // 任务编号 + RunId string `json:"run_id,omitempty" bson:"run_id,omitempty"` // 执行编号 + OutsideIp string `json:"outside_ip,omitempty" bson:"outside_ip,omitempty"` // 外网ip + InsideIp string `json:"inside_ip,omitempty" bson:"inside_ip,omitempty"` // 内网ip + Os string `json:"os,omitempty" bson:"os,omitempty"` // 系统类型 + Arch string `json:"arch,omitempty" bson:"arch,omitempty"` // 系统架构 + Gomaxprocs int `json:"gomaxprocs,omitempty" bson:"gomaxprocs,omitempty"` // CPU核数 + GoVersion string `json:"go_version,omitempty" bson:"go_version,omitempty"` // GO版本 + SdkVersion string `json:"sdk_version,omitempty" bson:"sdk_version,omitempty"` // SDK版本 + MacAddrs string `json:"mac_addrs,omitempty" bson:"mac_addrs,omitempty"` // Mac地址 + CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty"` // 创建时间 } func (TaskLogRun) TableName() string { diff --git a/jobs_xorm_model/task_log_run.go b/jobs_xorm_model/task_log_run.go index e0d4c59..dff560f 100644 --- a/jobs_xorm_model/task_log_run.go +++ b/jobs_xorm_model/task_log_run.go @@ -11,6 +11,7 @@ type TaskLogRun struct { Arch string `json:"arch"` // 系统架构 Gomaxprocs int `json:"gomaxprocs"` // CPU核数 GoVersion string `json:"go_version"` // GO版本 + SdkVersion string `json:"sdk_version"` // SDK版本 MacAddrs string `json:"mac_addrs"` // Mac地址 CreatedAt string `xorm:"created" json:"created_at"` // 创建时间 } diff --git a/run.go b/run.go index 2b3190d..1c69bee 100644 --- a/run.go +++ b/run.go @@ -124,6 +124,7 @@ func (c *Client) RunAddLog(id uint, runId string) error { Arch: c.config.arch, Gomaxprocs: c.config.maxProCs, GoVersion: c.config.version, + SdkVersion: c.config.runVersion, MacAddrs: c.config.macAddrS, CreatedAt: primitive.NewDateTimeFromTime(gotime.Current().Time), }) @@ -138,6 +139,7 @@ func (c *Client) RunAddLog(id uint, runId string) error { Arch: c.config.arch, Gomaxprocs: c.config.maxProCs, GoVersion: c.config.version, + SdkVersion: c.config.runVersion, MacAddrs: c.config.macAddrS, }).Error }