Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
so-operation-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
smart-operation
so-operation-api
Commits
996781d8
Commit
996781d8
authored
Jul 19, 2023
by
陈子龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
执行ansible命令日志存储缓存
parent
d80a9570
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
src/common/client/redis.go
src/common/client/redis.go
+5
-0
src/service/task_history.go
src/service/task_history.go
+14
-2
No files found.
src/common/client/redis.go
View file @
996781d8
...
@@ -108,6 +108,11 @@ func (r Redis) Exist(key string) (int64, error) {
...
@@ -108,6 +108,11 @@ func (r Redis) Exist(key string) (int64, error) {
return
r
.
Conn
.
Exists
(
strings
.
ToUpper
(
key
))
.
Result
()
return
r
.
Conn
.
Exists
(
strings
.
ToUpper
(
key
))
.
Result
()
}
}
func
(
r
Redis
)
HExists
(
key
,
field
string
)
(
bool
,
error
)
{
key
=
fmt
.
Sprintf
(
"%s-%s"
,
strings
.
ToUpper
(
r
.
Prefix
),
strings
.
ToUpper
(
key
))
return
r
.
Conn
.
HExists
(
strings
.
ToUpper
(
key
),
strings
.
ToUpper
(
field
))
.
Result
()
}
func
(
r
Redis
)
Keys
(
pattern
string
)
([]
string
,
error
)
{
func
(
r
Redis
)
Keys
(
pattern
string
)
([]
string
,
error
)
{
pattern
=
fmt
.
Sprintf
(
"%s-%s"
,
strings
.
ToUpper
(
r
.
Prefix
),
strings
.
ToUpper
(
pattern
))
pattern
=
fmt
.
Sprintf
(
"%s-%s"
,
strings
.
ToUpper
(
r
.
Prefix
),
strings
.
ToUpper
(
pattern
))
return
r
.
Conn
.
Keys
(
strings
.
ToUpper
(
pattern
))
.
Result
()
return
r
.
Conn
.
Keys
(
strings
.
ToUpper
(
pattern
))
.
Result
()
...
...
src/service/task_history.go
View file @
996781d8
...
@@ -142,12 +142,23 @@ func (t *TaskHistorySvc) TaskExecLog(id int) (taskExecLogRes response.TaskExecLo
...
@@ -142,12 +142,23 @@ func (t *TaskHistorySvc) TaskExecLog(id int) (taskExecLogRes response.TaskExecLo
err
=
resp
.
RedisConnectError
.
ErrorDetail
(
err1
)
err
=
resp
.
RedisConnectError
.
ErrorDetail
(
err1
)
return
return
}
}
value
,
err2
:=
redis
.
HGet
(
conf
.
AutoExecHistory
,
cast
.
ToString
(
id
))
//判断key值是否存在
b1
,
err2
:=
redis
.
HExists
(
conf
.
AutoExecHistory
,
cast
.
ToString
(
id
))
if
err2
!=
nil
{
if
err2
!=
nil
{
conf
.
Logger
.
Error
(
"redis H
Get
err"
,
zap
.
Error
(
err2
))
conf
.
Logger
.
Error
(
"redis H
Exists
err"
,
zap
.
Error
(
err2
))
err
=
resp
.
RedisExecError
.
ErrorDetail
(
err2
)
err
=
resp
.
RedisExecError
.
ErrorDetail
(
err2
)
}
if
!
b1
{
return
}
//获取key
value
,
err3
:=
redis
.
HGet
(
conf
.
AutoExecHistory
,
cast
.
ToString
(
id
))
if
err3
!=
nil
{
conf
.
Logger
.
Error
(
"redis HGet err"
,
zap
.
Error
(
err3
))
err
=
resp
.
RedisExecError
.
ErrorDetail
(
err3
)
return
return
}
}
//解析key
var
execCache
ExecCache
var
execCache
ExecCache
err
=
json
.
Unmarshal
([]
byte
(
value
),
&
execCache
)
err
=
json
.
Unmarshal
([]
byte
(
value
),
&
execCache
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -155,6 +166,7 @@ func (t *TaskHistorySvc) TaskExecLog(id int) (taskExecLogRes response.TaskExecLo
...
@@ -155,6 +166,7 @@ func (t *TaskHistorySvc) TaskExecLog(id int) (taskExecLogRes response.TaskExecLo
err
=
resp
.
FAIL
.
WithError
(
err
)
err
=
resp
.
FAIL
.
WithError
(
err
)
return
return
}
}
conf
.
Logger
.
Info
(
"redis HGet Log"
,
zap
.
String
(
"log"
,
execCache
.
ExecLog
))
taskExecLogRes
.
ExecLog
=
execCache
.
ExecLog
taskExecLogRes
.
ExecLog
=
execCache
.
ExecLog
taskExecLogRes
.
ExecEndTime
=
execCache
.
ExecEndTime
taskExecLogRes
.
ExecEndTime
=
execCache
.
ExecEndTime
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment