保存计划任务调整
This commit is contained in:
@@ -110,6 +110,7 @@ func (s *sGameAct) Set(uid int64, actId int, data interface{}) (err error) {
|
||||
|
||||
func (s *sGameAct) Saves(ctx context.Context) (err error) {
|
||||
getCache, _ := pkg.Cache("redis").Get(nil, "cron:game_act")
|
||||
g.Log().Debug(ctx, "开始执行游戏act数据保存了")
|
||||
//如果没有执行过,设置时间戳
|
||||
if getCache.Int64() > 0 {
|
||||
return
|
||||
@@ -122,8 +123,10 @@ func (s *sGameAct) Saves(ctx context.Context) (err error) {
|
||||
ActList.Iterator(func(i interface{}) bool {
|
||||
//在时间内允许执行
|
||||
if gtime.Now().Before(RunTimeMax) {
|
||||
g.Log().Errorf(ctx, "开始执行游戏act数据保存: act%v", i)
|
||||
g.Log().Debug(ctx, "开始执行游戏act数据保存: act%v", i)
|
||||
err = s.Save(ctx, i.(int))
|
||||
} else {
|
||||
g.Log().Errorf(ctx, "游戏act数据保存超时: act=%v", i)
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
@@ -56,7 +56,7 @@ func (s *sGameKv) SavesV1() (err error) {
|
||||
err = tools.Redis.RedisScanV2("user:kv:*", func(keys []string) (err error) {
|
||||
//判断是否超时
|
||||
if gtime.Now().After(RunTimeMax) {
|
||||
g.Log().Debug(ctx, "执行超时了,停止执行!")
|
||||
g.Log().Error(ctx, "执行超时了,停止执行!")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package utility_go
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/ayflying/utility_go/config"
|
||||
"github.com/ayflying/utility_go/internal/boot"
|
||||
_ "github.com/ayflying/utility_go/internal/logic"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/os/gtimer"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -14,9 +18,12 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
g.Log().Debug(ctx, "utility_go init启动完成")
|
||||
// 初始化配置
|
||||
var err = boot.Boot()
|
||||
gtimer.SetTimeout(ctx, time.Second*5, func(ctx context.Context) {
|
||||
err = boot.Boot()
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
Reference in New Issue
Block a user