[agent-go] fix-bugs

This commit is contained in:
zeaslity
2023-03-30 16:10:34 +08:00
parent d24a338e80
commit 61481e7543
6 changed files with 27 additions and 6 deletions

View File

@@ -74,7 +74,6 @@ func PipeLineCommandExecutor(pipeLineCommand [][]string) ([]string, error) {
lastCmd := cmds[len(cmds)-1] lastCmd := cmds[len(cmds)-1]
var out bytes.Buffer var out bytes.Buffer
lastCmd.Stdout = &out lastCmd.Stdout = &out
lastCmd.Stderr = &out lastCmd.Stderr = &out
err := lastCmd.Run() err := lastCmd.Run()
@@ -95,13 +94,12 @@ func PipeLineCommandExecutor(pipeLineCommand [][]string) ([]string, error) {
func MultiLineCommandExecutor(multiLineCommandExecutor [][]string) ([]string, error) { func MultiLineCommandExecutor(multiLineCommandExecutor [][]string) ([]string, error) {
var res []string var res []string
for _, singleLineCommand := range multiLineCommandExecutor { for _, singleLineCommand := range multiLineCommandExecutor {
singleLogs, err := SingleLineCommandExecutor(singleLineCommand) singleLogs, err := SingleLineCommandExecutor(singleLineCommand)
res := append(res, singleLogs...) res = append(res, singleLogs...)
if err != nil { if err != nil {
log.Error(fmt.Sprintf("Execution error ! command is %v, error is %v", singleLineCommand, err))
return res, err return res, err
} }

View File

@@ -65,7 +65,9 @@ func BuildOMsgRuntimeConnectorQueue(agentTopicName string) {
} }
// 策略模式 处理消息 // 策略模式 处理消息
om.Handle() P.Submit(func() {
om.Handle()
})
} }
}) })

View File

@@ -140,6 +140,10 @@ func handleInitMsgFromServer(initFromServerQueue *rabbitmq.RabbitQueue, initToSe
// 不是自身的 注册回复信息 -- 拒绝 // 不是自身的 注册回复信息 -- 拒绝
log.Warn(fmt.Sprintf("OctopusMessage INIT from server not this agent ! => %v, ==>%s", initOctopusMsg, delivery.Body)) log.Warn(fmt.Sprintf("OctopusMessage INIT from server not this agent ! => %v, ==>%s", initOctopusMsg, delivery.Body))
delivery.Nack(false, true) delivery.Nack(false, true)
// 需要休眠等待不再获取相应的信息
time.Sleep(5 * time.Second)
} }
} }

View File

@@ -0,0 +1,8 @@
{
"uuid": "2023-03-27 14:38:49",
"init_time": "2023-03-27T14:38:49.8162801+08:00",
"type": "EXECUTOR",
"content": "{\n \"needResultReplay\": true,\n \"durationTask,default:false\": false,\n \"type\": \"pipeline\",\n \"singleLineCommand\": null,\n \"multiLineCommand\": [[\"ls\",\"-l\"],[\"pwd\"]],\n \"pipeLineCommand\": null,\n \"resultKey\": \"output\"\n}",
"result": "",
"ac_time": "0001-01-01T00:00:00Z"
}

View File

@@ -0,0 +1,9 @@
{
"uuid": "2023-03-27 14:38:49",
"init_time": "2023-03-27T14:38:49.8162801+08:00",
"type": "EXECUTOR",
"content": "{\n \"needResultReplay\": true,\n \"durationTask,default:false\": false,\n \"type\": \"pipeline\",\n \"singleLineCommand\": null,\n \"multiLineCommand\": null,\n \"pipeLineCommand\": [[\"echo\",\"yes china\"],[\"awk\",\"'{print$2}'\"]],\n \"resultKey\": \"output\"\n}\n",
"result": "",
"ac_time": "0001-01-01T00:00:00Z"
}

View File

@@ -2,7 +2,7 @@
"uuid": "2023-03-27 14:38:49", "uuid": "2023-03-27 14:38:49",
"init_time": "2023-03-27T14:38:49.8162801+08:00", "init_time": "2023-03-27T14:38:49.8162801+08:00",
"type": "EXECUTOR", "type": "EXECUTOR",
"content": "{\n \"needResultReplay\": true,\n \"durationTask,default:false\": false,\n \"type\": \"command\",\n \"singleLineCommand\": [\n \"ls\",\n \"-la\"\n ],\n \"multiLineCommand\": null,\n \"pipeLineCommand\": null,\n \"resultKey\": \"output\"\n}\n", "content": "{\n \"needResultReplay\": true,\n \"durationTask,default:false\": false,\n \"type\": \"command\",\n \"singleLineCommand\": [\n \"ls\",\n \"-l\"\n ],\n \"multiLineCommand\": null,\n \"pipeLineCommand\": null,\n \"resultKey\": \"output\"\n}\n",
"result": "", "result": "",
"ac_time": "0001-01-01T00:00:00Z" "ac_time": "0001-01-01T00:00:00Z"
} }