From a21b113340c909321018857a8e7f7ea924f55bec Mon Sep 17 00:00:00 2001 From: zeaslity Date: Fri, 12 Apr 2024 14:36:22 +0800 Subject: [PATCH] [ Cmii ] [ Operator ] - bug fix --- agent-go/rabbitmq/RabbitMsgQueue.go | 4 ++-- agent-go/shell/base-agent-sync-offline.sh | 26 +++++++++++++++-------- server/src/main/resources/application.yml | 6 +++--- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/agent-go/rabbitmq/RabbitMsgQueue.go b/agent-go/rabbitmq/RabbitMsgQueue.go index f208d30..ae60fd3 100644 --- a/agent-go/rabbitmq/RabbitMsgQueue.go +++ b/agent-go/rabbitmq/RabbitMsgQueue.go @@ -196,7 +196,7 @@ func (r *RabbitQueue) Handle() chan bool { deliveries := r.Read(true) // 2024年4月9日 - r.ConsumeOK.Swap(true) + r.ConsumeOK.Store(true) foreverHandle := make(chan bool) // 死循环,处理Octopus Message @@ -217,7 +217,7 @@ func (r *RabbitQueue) Handle() chan bool { // 2024年4月9日 if !r.ConsumeOK.Load() { - log.InfoF("Rabbit Queue of [%s] [%s[ disconnect!", r.RabbitProp.ExchangeName, r.RabbitProp.QueueName) + log.InfoF("Rabbit Queue of [%s] [%s] disconnect!", r.RabbitProp.ExchangeName, r.RabbitProp.QueueName) break } } diff --git a/agent-go/shell/base-agent-sync-offline.sh b/agent-go/shell/base-agent-sync-offline.sh index b98cc9a..886004f 100644 --- a/agent-go/shell/base-agent-sync-offline.sh +++ b/agent-go/shell/base-agent-sync-offline.sh @@ -11,16 +11,23 @@ agent_offline_proxy_conf=https://oss-1.107421.xyz/octopus-offline-nginx.conf default_octopus_agent_local_path=/data/github-action/octopus-agent/ default_octopus_agent_config_local_path=/data/github-action/agent-config/ default_octopus_agent_version_local_path=/data/github-action/agent-version +agent_latest_version=2011-11-11-11 sync_octopus_agent() { - local octopus_agent_html="octopus_agent.html" + # 如果本地已经是最新版本 那么不要更新 + if ls ${default_octopus_agent_local_path} | grep -q "${agent_latest_version}";then + echo "agent already latest version => ${agent_latest_version}" + return 0 + fi + + local octopus_agent_html="octopus_agent_config.html" rm -rf ${octopus_agent_html} wget "$octopus_agent_url/" -qO ${octopus_agent_html} if [[ ! -s $octopus_agent_html ]]; then - echo "[sync_octopus_agent] - download agent version file error ! return false !" + echo "[sync_octopus_agent] - download agent file error ! return false !" return 233 fi @@ -30,14 +37,14 @@ sync_octopus_agent() { echo "" echo "开始同步最新版本的Octopus Agent !" - local octopus_agent_config_file_list="" + local octopus_agent_file_list="" # shellcheck disable=SC2034 - octopus_agent_config_file_list=$(cat ${octopus_agent_html} | grep -v h1 | grep "a href=" | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1 | tr "\n" " ") + octopus_agent_file_list=$(cat ${octopus_agent_html} | grep -v h1 | grep "a href=" | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1 | tr "\n" " ") local octopus_agent_config_list - IFS=" " read -ra octopus_agent_config_list <<<"$octopus_agent_config_file_list" + IFS=" " read -ra octopus_agent_file_list <<<"$octopus_agent_file_list" echo "" local octopus_agent_file - for octopus_agent_file in "${octopus_agent_config_list[@]}"; do + for octopus_agent_file in "${octopus_agent_file_list[@]}"; do echo "[sync_octopus_agent] => start to download => ${octopus_agent_url}/${octopus_agent_file}" wget "${octopus_agent_url}/${octopus_agent_file}" -qO "${default_octopus_agent_local_path}${octopus_agent_file}" echo "" @@ -109,7 +116,8 @@ sync_octopus_agent_config() { sync_octopus_agent_version() { # scp -P 22333 root@146.56.159.175:/data/ rm -rf ${default_octopus_agent_version_local_path} - curl -s -timeout=5 "${agent_version_url}" >${default_octopus_agent_version_local_path} + agent_latest_version=$(curl -s -timeout=5 "${agent_version_url}") + echo "${agent_latest_version}" > ${default_octopus_agent_version_local_path} echo "[sync_octopus_agent_version] - agent latest version is => $(cat $default_octopus_agent_version_local_path)" echo "" @@ -142,12 +150,12 @@ sync_octopus_offline_nginx_proxy_conf() { main() { + sync_octopus_agent_version + sync_octopus_agent sync_octopus_agent_config - sync_octopus_agent_version - sync_octopus_offline_nginx_proxy_conf } diff --git a/server/src/main/resources/application.yml b/server/src/main/resources/application.yml index 780e185..73c195a 100644 --- a/server/src/main/resources/application.yml +++ b/server/src/main/resources/application.yml @@ -9,7 +9,7 @@ spring: allow-circular-references: true allow-bean-definition-overriding: true rabbitmq: - host: 42.192.52.227 + host: 10.250.0.100 port: 20672 username: boge password: boge8tingH @@ -24,7 +24,7 @@ spring: max-interval: 65000 initial-interval: 65000 redis: - host: 42.192.52.227 + host: 10.250.0.100 port: 21370 database: 0 password: boge8tingH @@ -46,7 +46,7 @@ spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://42.192.52.227:21306/octopus_server?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8 + url: jdbc:mysql://10.250.0.100:21306/octopus_server?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8 username: boge password: boge8tingH type: com.zaxxer.hikari.HikariDataSource