diff --git a/agent-go/a_init/AgentInitialization.go b/agent-go/a_init/AgentInitialization.go index 8302a8a..6d82c51 100644 --- a/agent-go/a_init/AgentInitialization.go +++ b/agent-go/a_init/AgentInitialization.go @@ -28,20 +28,20 @@ func INIT(octopusAgentConfigFileName string, agentServerInfoConf string) chan bo agentServerInfo := parseAgentServerInfo(agentServerInfoConf) // todo totally get from a_status module + // 初始化Nacos的连接配置 + agentConfig := parseOctopusAgentConf(octopusAgentConfigFileName) + a_agent.AgentConfig = agentConfig + // re-get agentInfo from status module agentInfo := a_status.ReportAgentInfo() refreshAgentInfoByStatusInfo(agentInfo, agentServerInfo) // build operator cache - BuildAgentOsOperator(agentInfo, agentServerInfo) + buildAgentOsOperator(agentInfo, agentServerInfo) // 缓存此内容 a_agent.AgentServerInfoCache = agentServerInfo - // 初始化Nacos的连接配置 - agentConfig := ParseConfiguration(octopusAgentConfigFileName) - a_agent.AgentConfig = agentConfig - // build for octopus tcp connect info struct rabbitTCPConnectInfo := BuildOctopusTCPConnect(agentConfig) @@ -184,24 +184,18 @@ func buildAndSendInitMsgToServer(agentServerInfo *a_agent.AgentServerInfo, initT initOmType, agentServerInfo, ) - msgBytes, err := json.Marshal(octopusMsg) - if err != nil { - log.Error(fmt.Sprintf("octopus message convert to json is wrong! msg is => %v", octopusMsg)) - } // 发送OM至MQ中 - P.Submit( + _ = P.Submit( func() { for g.G.AgentHasRegister == false { - log.Debug(fmt.Sprintf("Send init message to server! ==> %s", string(msgBytes))) + log.InfoF("Send init message to server! ==> %s", octopusMsg) //如果agent存活 而Server不存活 那么需要持续不断的向Server中发送消息 - initToServerQueue.Send( - msgBytes, - ) + initToServerQueue.SendOMsg(octopusMsg) // 休眠 - time.Sleep(10 * time.Minute) + time.Sleep(5 * time.Minute) } }) } @@ -346,7 +340,7 @@ func UniformAgentServerInfo(agentServerInfo *a_agent.AgentServerInfo) { } -func BuildAgentOsOperator(agentInfo *a_status.AgentInfo, agentServerInfo *a_agent.AgentServerInfo) { +func buildAgentOsOperator(agentInfo *a_status.AgentInfo, agentServerInfo *a_agent.AgentServerInfo) { // 2023年8月4日 pass through some key information ossOfflinePrefix := "http://bastion.io" @@ -355,6 +349,8 @@ func BuildAgentOsOperator(agentInfo *a_status.AgentInfo, agentServerInfo *a_agen if !strings.HasSuffix(ossOfflinePrefix, "/") { ossOfflinePrefix += "/" } + } else { + log.WarnF("buildAgentOsOperator - agent oss offline prefix is null !") } // call the init exec function diff --git a/agent-go/a_init/BastionInitializaion.go b/agent-go/a_init/BastionInitializaion.go index 66c2990..dda49e2 100644 --- a/agent-go/a_init/BastionInitializaion.go +++ b/agent-go/a_init/BastionInitializaion.go @@ -42,7 +42,7 @@ func BastionModeInit() { // re-get agentInfo from status module agentInfo := a_status.ReportAgentInfo() refreshAgentInfoByStatusInfo(agentInfo, agentServerInfo) - BuildAgentOsOperator(agentInfo, agentServerInfo) + buildAgentOsOperator(agentInfo, agentServerInfo) // install docker agentOsOperator := a_executor.AgentOsOperatorCache diff --git a/agent-go/a_init/ConfigParser.go b/agent-go/a_init/ConfigParser.go index 3cce561..37f596a 100644 --- a/agent-go/a_init/ConfigParser.go +++ b/agent-go/a_init/ConfigParser.go @@ -5,7 +5,7 @@ import ( "github.com/spf13/viper" ) -func ParseConfiguration(configFileName string) *viper.Viper { +func parseOctopusAgentConf(configFileName string) *viper.Viper { agentConfig := parseAgentConfigFile(configFileName, nil)