mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-01-23 02:40:23 +08:00
修复在线修改定时任务多次执行时事务超时问题
This commit is contained in:
parent
7153327b13
commit
7cf1b8ce8e
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user