From efe7a836ba2b408a88448eec09e3a67d9c09ae24 Mon Sep 17 00:00:00 2001 From: zeaslity Date: Fri, 30 Jun 2023 15:43:37 +0800 Subject: [PATCH] =?UTF-8?q?[=20=E9=A1=B9=E7=9B=AE=20]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?CI=20CD=E6=B5=81=E7=A8=8B=20-=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent-go/AgentInitialization.go | 12 +-- agent-go/main.go | 7 +- agent-go/octopus-agent-shanghai.yaml | 91 +++++++++++++++++++ .../java/io/wdd/source/shell/agent-bootup.sh | 2 +- 4 files changed, 101 insertions(+), 11 deletions(-) create mode 100644 agent-go/octopus-agent-shanghai.yaml diff --git a/agent-go/AgentInitialization.go b/agent-go/AgentInitialization.go index 316590c..d4c8d13 100644 --- a/agent-go/AgentInitialization.go +++ b/agent-go/AgentInitialization.go @@ -17,10 +17,10 @@ var P = g.G.P var AgentServerInfoCache = ®ister.AgentServerInfo{} -func INIT() *register.AgentServerInfo { +func INIT(agentServerInfoConf string) *register.AgentServerInfo { // 获取系统的环境变量 - agentServerInfo := parseAgentServerInfo() + agentServerInfo := parseAgentServerInfo(agentServerInfoConf) agentConfig := g.G.AgentConfig @@ -164,13 +164,11 @@ func shutdownRegisterQueueConnection(initFromServerQueue *rabbitmq.RabbitQueue, log.InfoF("Pretend to Shutdown register queue connection !") } -func parseAgentServerInfo() *register.AgentServerInfo { +func parseAgentServerInfo(agentServerInfoConf string) *register.AgentServerInfo { - // 约定文件地址为 /etc/environment.d/octopus-agent.conf - // 目前使用 + // 约定文件地址为 /octopus-agent/octopus-agent.conf var agentServerInfo *register.AgentServerInfo - //yamlFile, err := ioutil.ReadFile("C:\\Users\\wdd\\IdeaProjects\\ProjectOctopus\\agent-go\\server-env.yaml") - yamlFile, err := ioutil.ReadFile("server-env.yaml") + yamlFile, err := ioutil.ReadFile(agentServerInfoConf) if err != nil { panic(fmt.Errorf("failed to read YAML file: %v", err)) diff --git a/agent-go/main.go b/agent-go/main.go index 41d4795..f74b36d 100644 --- a/agent-go/main.go +++ b/agent-go/main.go @@ -14,18 +14,19 @@ func main() { // 解析命令行参数 var version string - var agentInfoConf string + var agentServerInfoConf string flag.StringVar(&version, "version", "", "config file version") - flag.StringVar(&agentInfoConf, "agentInfoConf", "", "agent server info conf file") + flag.StringVar(&agentServerInfoConf, "agentServerInfoConf", "", "agent server info conf file") flag.Parse() // 读取对应版本的配置文件 filename := fmt.Sprintf("octopus-agent-%s.yaml", version) println("config file name is => " + filename) + println("agent server info file is => " + agentServerInfoConf) // 初始化Nacos的连接配置 g.G.AgentConfig = register.ParseConfiguration(filename) // 执行初始化之策工作 - AgentServerInfoCache = INIT() + AgentServerInfoCache = INIT(agentServerInfoConf) } diff --git a/agent-go/octopus-agent-shanghai.yaml b/agent-go/octopus-agent-shanghai.yaml new file mode 100644 index 0000000..e3c967a --- /dev/null +++ b/agent-go/octopus-agent-shanghai.yaml @@ -0,0 +1,91 @@ +server: + port: 8000 + +logging: + level: + web: info + +octopus: + message: + # agent boot up default common exchange + init_exchange: InitExchange + # server will send message to agent using this common queue + init_to_server: InitToServer + # agent boot up default common exchange routing key + init_to_server_key: InitToServerKey + # server will receive message from agent using this common queue + init_from_server: InitFromServer + # agent boot up default common exchange routing key + init_from_server_key: InitFromServerKey + # initialization register time out (unit ms) default is 5 min + init_ttl: "3000000" + # Octopus Exchange Name == server comunicate with agent + octopus_exchange: OctopusExchange + # Octopus Message To Server == all agent send info to server queue and topic + octopus_to_server: OctopusToServer + executor: + name: executor-functions + status: + name: octopus-agent + healthy: + type: cron + cron: 10 */1 * * * ? * + start-delay: 30 + metric: + pinch: 20 + agent: + executor: + # agent执行一条Command的最长超时时间 + processMaxTimeOut: 60 + status: + app: + - Nginx/nginx + - MySQL/mysql + - Xray/xray + - OctopusAgent/octopus-agent + - Redis/redis + - RabbitMQ/rabbitmq + +spring: + main: + allow-circular-references: true + allow-bean-definition-overriding: true + rabbitmq: + host: 42.192.52.227 + # host: 192.168.35.71 + port: 20672 + username: boge + password: boge8tingH + virtual-host: / + listener: + simple: + retry: + # ack failed will reentrant the Rabbit Listener + max-attempts: 2 + enabled: true + # retry interval unit ms + max-interval: 65000 + initial-interval: 65000 + +#spring: +# application: +# name: octopus-agent +# profiles: +# active: dev +# cloud: +# nacos: +# config: +# group: dev +# config-retry-time: 3000 +# file-extension: yaml +# max-retry: 3 +# # server-addr: "150.230.198.103:21060" +# server-addr: "42.192.52.227:21060" +# timeout: 5000 +# config-long-poll-timeout: 5000 +# extension-configs: +# - group: dev +# data-id: "common-dev.yaml" +# +#server: +# port: 8000 \ No newline at end of file diff --git a/source/src/main/java/io/wdd/source/shell/agent-bootup.sh b/source/src/main/java/io/wdd/source/shell/agent-bootup.sh index 8e1b97a..83a7d05 100644 --- a/source/src/main/java/io/wdd/source/shell/agent-bootup.sh +++ b/source/src/main/java/io/wdd/source/shell/agent-bootup.sh @@ -379,7 +379,7 @@ SyslogIdentifier=octopus-agent User=root Type=simple WorkingDirectory=/octopus-agent -ExecStart=/octpus-agent/octopus-agent -agentInfoConf=/octpus-agent/octopus-agent.conf +ExecStart=/octpus-agent/octopus-agent -agentServerInfoConf=/octpus-agent/octopus-agent.conf -version=shanghai ExecStop=/bin/kill -15 \$MAINPID [Install]