feat: 完善堡垒机与 Agent 智能运维能力
- 支持 Windows Agent 构建、安装脚本和统一上报协议 - 增强 RDP 剪贴板、虚拟盘和文件传输能力 - 新增 AIOps 上下文工具、告警 RCA trace 落库和回放接口 - 重构 docs 模块文档并补充终端、堡垒机、监控、AI Agent 设计
This commit is contained in:
1 parent
a9513c2056
commit
e0d652d211
169 files changed
+12192
-9116
No files matched your search
@@ -299,45 +299,41 @@ func (h *AutomationHandler) ExecuteScript(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
go h.finishScriptExecution(script, execution.ID)
|
||||
|
||||
c.JSON(http.StatusOK, model.Response{
|
||||
Code: 200,
|
||||
Message: "已提交后台执行",
|
||||
Data: execution,
|
||||
})
|
||||
}
|
||||
|
||||
// finishScriptExecution 在后台完成脚本执行,HTTP 请求只负责提交任务 // Logan.Li
|
||||
func (h *AutomationHandler) finishScriptExecution(script model.Script, executionID uint) {
|
||||
rt := scriptrunner.DetectRuntime()
|
||||
if ok, reason := scriptrunner.CanRun(rt, script.Type); !ok {
|
||||
c.JSON(http.StatusBadRequest, model.Response{
|
||||
Code: 400,
|
||||
Message: reason,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 在 AIOps 本机执行(embed 单二进制 / Docker 容器内)
|
||||
output, exitCode, duration := runLocal(script.Type, script.Content, script.Timeout)
|
||||
finishedAt := time.Now()
|
||||
status := "success"
|
||||
if exitCode != 0 {
|
||||
output := ""
|
||||
exitCode := 0
|
||||
duration := 0
|
||||
if ok, reason := scriptrunner.CanRun(rt, script.Type); !ok {
|
||||
status = "failed"
|
||||
exitCode = -1
|
||||
output = reason + "\n"
|
||||
} else {
|
||||
output, exitCode, duration = runLocal(script.Type, script.Content, script.Timeout)
|
||||
if exitCode != 0 {
|
||||
status = "failed"
|
||||
}
|
||||
}
|
||||
|
||||
h.db.Model(&execution).Updates(map[string]interface{}{
|
||||
finishedAt := time.Now()
|
||||
h.db.Model(&model.TaskExecution{}).Where("id = ?", executionID).Updates(map[string]interface{}{
|
||||
"status": status,
|
||||
"output": output,
|
||||
"duration": duration,
|
||||
"finished_at": finishedAt,
|
||||
})
|
||||
h.db.Model(&script).UpdateColumn("run_count", script.RunCount+1)
|
||||
|
||||
execution.Output = output
|
||||
execution.Status = status
|
||||
execution.Duration = duration
|
||||
execution.FinishedAt = &finishedAt
|
||||
|
||||
msg := "执行成功"
|
||||
if status == "failed" {
|
||||
msg = "执行失败"
|
||||
}
|
||||
c.JSON(http.StatusOK, model.Response{
|
||||
Code: 200,
|
||||
Message: msg,
|
||||
Data: execution,
|
||||
})
|
||||
h.db.Model(&model.Script{}).Where("id = ?", script.ID).UpdateColumn("run_count", script.RunCount+1)
|
||||
_ = exitCode
|
||||
}
|
||||
|
||||
// ListExecutions 获取任务执行记录列表
|
||||
|
||||
Reference in new issue
Block a user