diff --git a/src/service/task_manage.go b/src/service/task_manage.go index c6b58cef82f466ab21642aeb38a0f4516baec4a8..f60de1f927e486e36582d2eae1a6b9a0deefcbc8 100644 --- a/src/service/task_manage.go +++ b/src/service/task_manage.go @@ -395,7 +395,6 @@ func ExecAnsible(id, taskId int, value string) { zap.L().Error(err.Error()) } for { - //逐行输出日志 lineOut, err1 := outputBuf.ReadString('\n') if (err1 != nil || io.EOF == err1) && out == 0 { @@ -403,19 +402,10 @@ func ExecAnsible(id, taskId int, value string) { } else if out == 0 { //存储执行日志 execLog = execLog + lineOut + " \n " - //err = UpdateExecHistory(request.UpdateExecHistory{ - // TaskHistoryId: id, - // ExecLog: execLog, - //}) - //if err != nil { - // conf.Logger.Error("Store Execution Log", zap.Error(err)) - // //return - //} - // TODO 写缓存 + // 写缓存 err = redis.HSet(conf.AutoExecHistory, strconv.Itoa(id), execLog) if err != nil { conf.Logger.Error("Store Execution Log", zap.Error(err)) - //return } } @@ -425,22 +415,12 @@ func ExecAnsible(id, taskId int, value string) { } else if outErr == 0 { //存储异常执行日志 execLog = execLog + lineErr + " \n " - //err = UpdateExecHistory(request.UpdateExecHistory{ - // TaskHistoryId: id, - // ExecLog: execLog, - //}) - //if err != nil { - // conf.Logger.Error("Store abnormal execution logs", zap.Error(err)) - // //return - //} - // TODO 写缓存 + // 写缓存 err = redis.HSet(conf.AutoExecHistory, strconv.Itoa(id), execLog) if err != nil { conf.Logger.Error("Store Execution Log", zap.Error(err)) - //return } } - if out == 1 && outErr == 1 { break } @@ -458,7 +438,7 @@ func ExecAnsible(id, taskId int, value string) { conf.Logger.Error("Modify Execution Status", zap.Error(err)) //return } - redis.Del(strconv.Itoa(id)) + redis.HDel(conf.AutoExecHistory, strconv.Itoa(id)) } else { //任务执行失败 err = UpdateExecHistory(request.UpdateExecHistory{ @@ -470,7 +450,6 @@ func ExecAnsible(id, taskId int, value string) { conf.Logger.Error("Modify Execution Status", zap.Error(err)) //return } - redis.Del(strconv.Itoa(id)) + redis.HDel(conf.AutoExecHistory, strconv.Itoa(id)) } - //return }