Commit 201e533d authored by 陈子龙's avatar 陈子龙

执行ansible命令日志存储缓存

parent 7a49adf2
...@@ -170,12 +170,14 @@ func (t *TaskHistorySvc) TaskExecLog(id int) (taskExecLogRes response.TaskExecLo ...@@ -170,12 +170,14 @@ func (t *TaskHistorySvc) TaskExecLog(id int) (taskExecLogRes response.TaskExecLo
err = resp.FAIL.WithError(errMarshal) err = resp.FAIL.WithError(errMarshal)
return return
} }
// 写缓存 if taskExecLogRes.State == 0 {
err = redis.HSet(conf.TaskExecLog, strconv.Itoa(id), fmt.Sprintf("%s", taskExecLog)) // 写缓存
if err != nil { err = redis.HSet(conf.TaskExecLog, strconv.Itoa(id), fmt.Sprintf("%s", taskExecLog))
conf.Logger.Error("Failed to execute history cache err", zap.Error(err)) if err != nil {
err = resp.FAIL.WithError(err) conf.Logger.Error("Failed to execute history cache err", zap.Error(err))
return err = resp.FAIL.WithError(err)
return
}
} }
} }
......
...@@ -468,6 +468,8 @@ func ExecAnsible(id, taskId int, value string) { ...@@ -468,6 +468,8 @@ func ExecAnsible(id, taskId int, value string) {
//return //return
} }
} }
err = redis.HDel(conf.TaskExecLog, strconv.Itoa(id))
conf.Logger.Error("del redis err", zap.Error(err))
redis.HDel(conf.AutoExecHistory, strconv.Itoa(id)) redis.HDel(conf.AutoExecHistory, strconv.Itoa(id))
redis.HDel(conf.TaskExecLog, strconv.Itoa(id))
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment