[ 项目 ] 修改CI CD流程 - 2

This commit is contained in:
zeaslity
2023-06-30 15:43:37 +08:00
parent 70e8d12f24
commit efe7a836ba
4 changed files with 101 additions and 11 deletions

View File

@@ -17,10 +17,10 @@ var P = g.G.P
var AgentServerInfoCache = &register.AgentServerInfo{} var AgentServerInfoCache = &register.AgentServerInfo{}
func INIT() *register.AgentServerInfo { func INIT(agentServerInfoConf string) *register.AgentServerInfo {
// 获取系统的环境变量 // 获取系统的环境变量
agentServerInfo := parseAgentServerInfo() agentServerInfo := parseAgentServerInfo(agentServerInfoConf)
agentConfig := g.G.AgentConfig agentConfig := g.G.AgentConfig
@@ -164,13 +164,11 @@ func shutdownRegisterQueueConnection(initFromServerQueue *rabbitmq.RabbitQueue,
log.InfoF("Pretend to Shutdown register queue connection !") 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 var agentServerInfo *register.AgentServerInfo
//yamlFile, err := ioutil.ReadFile("C:\\Users\\wdd\\IdeaProjects\\ProjectOctopus\\agent-go\\server-env.yaml") yamlFile, err := ioutil.ReadFile(agentServerInfoConf)
yamlFile, err := ioutil.ReadFile("server-env.yaml")
if err != nil { if err != nil {
panic(fmt.Errorf("failed to read YAML file: %v", err)) panic(fmt.Errorf("failed to read YAML file: %v", err))

View File

@@ -14,18 +14,19 @@ func main() {
// 解析命令行参数 // 解析命令行参数
var version string var version string
var agentInfoConf string var agentServerInfoConf string
flag.StringVar(&version, "version", "", "config file version") 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() flag.Parse()
// 读取对应版本的配置文件 // 读取对应版本的配置文件
filename := fmt.Sprintf("octopus-agent-%s.yaml", version) filename := fmt.Sprintf("octopus-agent-%s.yaml", version)
println("config file name is => " + filename) println("config file name is => " + filename)
println("agent server info file is => " + agentServerInfoConf)
// 初始化Nacos的连接配置 // 初始化Nacos的连接配置
g.G.AgentConfig = register.ParseConfiguration(filename) g.G.AgentConfig = register.ParseConfiguration(filename)
// 执行初始化之策工作 // 执行初始化之策工作
AgentServerInfoCache = INIT() AgentServerInfoCache = INIT(agentServerInfoConf)
} }

View File

@@ -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

View File

@@ -379,7 +379,7 @@ SyslogIdentifier=octopus-agent
User=root User=root
Type=simple Type=simple
WorkingDirectory=/octopus-agent 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 ExecStop=/bin/kill -15 \$MAINPID
[Install] [Install]