[Cmii][ImageSync] - reformat agent-go - 2
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package a_agent
|
||||
|
||||
import (
|
||||
"time"
|
||||
"wdd.io/agent-common/logger"
|
||||
"wdd.io/agent-go/rabbitmq"
|
||||
)
|
||||
@@ -11,7 +12,7 @@ func Activate() {
|
||||
log.Info("Module [ AGENT ] activated !")
|
||||
|
||||
for {
|
||||
if octopusMessage, ok := <-rabbitmq.BusinessRuntimeQueue.ReceiveChan.ExecutorRChan; ok {
|
||||
if octopusMessage, ok := <-rabbitmq.BusinessRuntimeQueue.ReceiveChan.AgentRChan; ok {
|
||||
// 处理数
|
||||
|
||||
// 输出日志
|
||||
@@ -21,5 +22,6 @@ func Activate() {
|
||||
log.ErrorF("business queue [ AGENT ] receive chan has closed !")
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Second * 20)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"wdd.io/agent-common/logger"
|
||||
"wdd.io/agent-common/utils"
|
||||
"wdd.io/agent-go/rabbitmq"
|
||||
@@ -70,6 +71,7 @@ func Activate() {
|
||||
break
|
||||
}
|
||||
}
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
|
||||
func Execute(em *ExecutionMessage) (bool, []string) {
|
||||
|
||||
@@ -96,9 +96,6 @@ func INIT(octopusAgentConfigFileName string, agentServerInfoConf string) chan bo
|
||||
}
|
||||
}
|
||||
|
||||
//<-initForeverHandle
|
||||
//close(initFromServerQueue.ReceiveChan.InitRChan)
|
||||
|
||||
// 建立 运行时 RabbitMQ连接
|
||||
runtimeConnectorQueue := buildAndStartBusinessRuntimeQueue(a_agent.AgentServerInfoCache.TopicName)
|
||||
|
||||
@@ -153,6 +150,7 @@ func buildAndStartBusinessRuntimeQueue(agentTopicName string) chan bool {
|
||||
|
||||
// cache it
|
||||
rabbitmq.BusinessRuntimeQueue = octopusMsgQueue
|
||||
rabbitmq.OctopusToServerQueue = octopusToServerQueue
|
||||
|
||||
return businessForeverChan
|
||||
}
|
||||
@@ -161,12 +159,9 @@ func buildAndStartBusinessRuntimeQueue(agentTopicName string) chan bool {
|
||||
func activatedOctopusAgentModules() {
|
||||
|
||||
// Agent
|
||||
err := P.Submit(func() {
|
||||
_ = P.Submit(func() {
|
||||
a_agent.Activate()
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// Executor
|
||||
_ = P.Submit(func() {
|
||||
a_executor.Activate()
|
||||
|
||||
@@ -48,7 +48,7 @@ func Activate() {
|
||||
|
||||
// 死循环获取channel中的数据
|
||||
for {
|
||||
if octopusMessage, ok := <-rabbitmq.BusinessRuntimeQueue.ReceiveChan.ExecutorRChan; ok {
|
||||
if octopusMessage, ok := <-rabbitmq.BusinessRuntimeQueue.ReceiveChan.StatusRChan; ok {
|
||||
// 处理数据
|
||||
|
||||
statusMsgString := octopusMessage.Content.(string)
|
||||
@@ -90,6 +90,8 @@ func Activate() {
|
||||
log.ErrorF("business queue [ STATUS ] receive chan has closed !")
|
||||
break
|
||||
}
|
||||
|
||||
time.Sleep(time.Second * 20)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ import (
|
||||
"wdd.io/agent-go/g"
|
||||
)
|
||||
|
||||
var OctopusToServerQueue = &RabbitQueue{}
|
||||
|
||||
var P = g.G.P
|
||||
|
||||
type OctopusMsgHandler interface {
|
||||
|
||||
@@ -9,8 +9,12 @@ import (
|
||||
"wdd.io/agent-common/logger"
|
||||
)
|
||||
|
||||
// BusinessRuntimeQueue octopus message from server
|
||||
var BusinessRuntimeQueue = &RabbitQueue{}
|
||||
|
||||
// OctopusToServerQueue octopus message to server
|
||||
var OctopusToServerQueue = &RabbitQueue{}
|
||||
|
||||
type RabbitMQ interface {
|
||||
RabbitSendWriter
|
||||
RabbitConnectCloser
|
||||
|
||||
Reference in New Issue
Block a user