fix 定时任务管理

This commit is contained in:
陈景阳
2019-10-11 23:22:25 +08:00
parent 8eef98e082
commit b56399451e
2 changed files with 12 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ import (
"os"
"path/filepath"
"runtime/debug"
"time"
)
// 任务日志频道映射
@@ -45,8 +46,14 @@ func GetRemoteLog(task model.Task) (logStr string, err error) {
// 生成频道等待获取log
ch := TaskLogChanMap.ChanBlocked(task.Id)
// 此处阻塞,等待结果
logStr = <-ch
select {
case logStr = <-ch:
log.Infof("get remote log")
break
case <-time.After(5 * time.Second):
logStr = "get remote log timeout"
break
}
return logStr, nil
}

View File

@@ -285,6 +285,9 @@ func ExecuteTask(id int) {
// 节点队列任务
var msg string
msg, err = database.RedisClient.LPop(queueCur)
if msg != "" {
log.Infof("queue cur: %s", msg)
}
if err != nil {
if msg == "" {
// 节点队列没有任务,获取公共队列任务