修复在线修改定时任务多次执行时事务超时问题

This commit is contained in:
孟帅 2023-02-09 15:42:30 +08:00
parent 7153327b13
commit 7cf1b8ce8e
4 changed files with 17 additions and 7 deletions

View File

@ -139,7 +139,6 @@ func RefreshStatus(sysCron *entity.SysCron) (err error) {
if sysCron == nil {
return
}
g.DumpWithType(sysCron)
if sysCron.Status == consts.StatusEnabled {
return Start(sysCron)

View File

@ -18,11 +18,11 @@ import (
// AccessLog 访问日志
func (s *sHook) AccessLog(r *ghttp.Request) {
var (
ctx = r.Context()
)
if r.IsFileRequest() {
return
}
// 没有上下文的请求不记录doc、favicon.ico等非功能类业务
var ctx = r.Context()
modelCtx := contexts.Get(ctx)
if modelCtx == nil {
return

View File

@ -60,6 +60,10 @@ func allow(memberId int64) bool {
// LastActive 更新用户最后活跃
func (s *sHook) LastActive(r *ghttp.Request) {
if r.IsFileRequest() {
return
}
var (
ctx = r.Context()
memberId = contexts.GetUserId(ctx)

View File

@ -19,6 +19,7 @@ import (
"hotgo/internal/model/input/form"
"hotgo/internal/model/input/sysin"
"hotgo/internal/service"
"hotgo/utility/simple"
"hotgo/utility/validate"
"strings"
)
@ -90,7 +91,10 @@ func (s *sSysCron) Edit(ctx context.Context, in sysin.CronEditInp) (err error) {
return err
}
return crons.RefreshStatus(&in.SysCron)
simple.SafeGo(ctx, func(ctx context.Context) {
crons.RefreshStatus(&in.SysCron)
})
return
})
return
}
@ -136,7 +140,10 @@ func (s *sSysCron) Status(ctx context.Context, in sysin.CronStatusInp) (err erro
}
models.Status = in.Status
return crons.RefreshStatus(models)
simple.SafeGo(ctx, func(ctx context.Context) {
crons.RefreshStatus(models)
})
return
})
return
}