[Cmii][ImageSync] - reformat agent-go - 2
This commit is contained in:
@@ -73,31 +73,33 @@ func INIT(octopusAgentConfigFileName string, agentServerInfoConf string) chan bo
|
||||
|
||||
// 监听初始化连接中的信息
|
||||
initFromServerQueue := &rabbitmq.RabbitQueue{
|
||||
RabbitProp: initFromServerProp,
|
||||
RabbitProp: initFromServerProp,
|
||||
RabbitConnectInfo: rabbitTCPConnectInfo,
|
||||
}
|
||||
//defer initFromServerQueue.Close()
|
||||
|
||||
// 建立连接
|
||||
initFromServerQueue.Connect()
|
||||
|
||||
initForeverHandle := initFromServerQueue.Handle()
|
||||
initFromServerQueue.Handle()
|
||||
|
||||
buildAndSendInitMsgToServer(agentServerInfo, initToServerQueue)
|
||||
|
||||
// receive from server
|
||||
for g.G.AgentHasRegister == false {
|
||||
select {
|
||||
case <-initFromServerQueue.ReceiveChan.InitRChan:
|
||||
initFromServerMsg := <-initFromServerQueue.ReceiveChan.InitRChan
|
||||
handleInitMsgFromServer(initFromServerMsg, initToServerQueue, agentServerInfo)
|
||||
case initFromServerMsg := <-initFromServerQueue.ReceiveChan.InitRChan:
|
||||
if handleInitMsgFromServer(initFromServerMsg, initToServerQueue, agentServerInfo) {
|
||||
break
|
||||
}
|
||||
default:
|
||||
//log.Debug("")
|
||||
log.Debug("agent init not received from server ! start to waiting !")
|
||||
time.Sleep(time.Second * 10)
|
||||
}
|
||||
}
|
||||
|
||||
<-initForeverHandle
|
||||
close(initFromServerQueue.ReceiveChan.InitRChan)
|
||||
//<-initForeverHandle
|
||||
//close(initFromServerQueue.ReceiveChan.InitRChan)
|
||||
|
||||
// 建立 运行时 RabbitMQ连接
|
||||
runtimeConnectorQueue := buildAndStartBusinessRuntimeQueue(a_agent.AgentServerInfoCache.TopicName)
|
||||
@@ -194,7 +196,7 @@ func buildAndSendInitMsgToServer(agentServerInfo *a_agent.AgentServerInfo, initT
|
||||
})
|
||||
}
|
||||
|
||||
func BuildOctopusTCPConnect(agentConfig *viper.Viper) rabbitmq.RabbitTCPConnectInfo {
|
||||
func BuildOctopusTCPConnect(agentConfig *viper.Viper) *rabbitmq.RabbitTCPConnectInfo {
|
||||
host := agentConfig.GetString("spring.rabbitmq.host")
|
||||
port := agentConfig.GetString("spring.rabbitmq.port")
|
||||
username := agentConfig.GetString("spring.rabbitmq.username")
|
||||
@@ -202,7 +204,7 @@ func BuildOctopusTCPConnect(agentConfig *viper.Viper) rabbitmq.RabbitTCPConnectI
|
||||
virtualHost := agentConfig.GetString("spring.rabbitmq.virtual-host")
|
||||
|
||||
//todo
|
||||
return rabbitmq.RabbitTCPConnectInfo{
|
||||
return &rabbitmq.RabbitTCPConnectInfo{
|
||||
UserName: username,
|
||||
Password: password,
|
||||
Host: host,
|
||||
@@ -227,7 +229,7 @@ func handleInitMsgFromServer(initFromServerMsg *rabbitmq.OctopusMessage, initToS
|
||||
|
||||
//initOctopusMessageDeliveries := initFromServerQueue.Read(false)
|
||||
|
||||
log.Debug(fmt.Sprintf("message received from server is %s", &initFromServerMsg))
|
||||
log.DebugF("message received from server is %s", initFromServerMsg)
|
||||
|
||||
var serverInfo a_agent.AgentServerInfo
|
||||
|
||||
|
||||
55
agent-go/a_init/BastionInitializaion.go
Normal file
55
agent-go/a_init/BastionInitializaion.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package a_init
|
||||
|
||||
import (
|
||||
"wdd.io/agent-go/a_agent"
|
||||
"wdd.io/agent-go/a_executor"
|
||||
"wdd.io/agent-go/a_status"
|
||||
)
|
||||
|
||||
func BastionModeInit() {
|
||||
|
||||
// Build For Operator
|
||||
agentServerInfo := &a_agent.AgentServerInfo{
|
||||
ServerName: "BastionSingle",
|
||||
ServerIPPbV4: "127.0.0.1",
|
||||
ServerIPInV4: "127.0.0.1",
|
||||
ServerIPPbV6: "",
|
||||
ServerIPInV6: "",
|
||||
Location: "Bastion",
|
||||
Provider: "Bastion",
|
||||
ManagePort: "22",
|
||||
CPUCore: "",
|
||||
CPUBrand: "",
|
||||
OSInfo: "",
|
||||
OSKernelInfo: "",
|
||||
TCPControl: "",
|
||||
Virtualization: "",
|
||||
Platform: "",
|
||||
PlatformFamily: "",
|
||||
PlatformVersion: "",
|
||||
KernelVersion: "",
|
||||
KernelArch: "",
|
||||
IoSpeed: "",
|
||||
MemoryTotal: "",
|
||||
DiskTotal: "",
|
||||
DiskUsage: "",
|
||||
Comment: "",
|
||||
MachineID: "",
|
||||
AgentVersion: "",
|
||||
TopicName: "BastionNode",
|
||||
}
|
||||
|
||||
// re-get agentInfo from status module
|
||||
agentInfo := a_status.ReportAgentInfo()
|
||||
refreshAgentInfoByStatusInfo(agentInfo, agentServerInfo)
|
||||
BuildAgentOsOperator(agentInfo, agentServerInfo)
|
||||
|
||||
// install docker
|
||||
agentOsOperator := a_executor.AgentOsOperatorCache
|
||||
// boot up minio & rabbitmq
|
||||
agentOsOperator.InstallDockerFromLocalExec(nil)
|
||||
agentOsOperator.InstallDockerComposeFromLocalExec()
|
||||
|
||||
// build for socks server
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user