[ 项目 ] 修改CI CD流程

This commit is contained in:
zeaslity
2023-06-30 15:18:15 +08:00
parent 6acb5e8141
commit 1e20429b3a
6 changed files with 59 additions and 126 deletions

View File

@@ -14,7 +14,9 @@ func main() {
// 解析命令行参数 // 解析命令行参数
var version string var version string
var agentInfoConf 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.Parse() flag.Parse()
// 读取对应版本的配置文件 // 读取对应版本的配置文件
filename := fmt.Sprintf("octopus-agent-%s.yaml", version) filename := fmt.Sprintf("octopus-agent-%s.yaml", version)

View File

@@ -78,18 +78,9 @@ public class OctopusAgentServiceImpl implements OctopusAgentService {
CountDownLatch countDownLatch = agentReplayContend.getCountDownLatch(); CountDownLatch countDownLatch = agentReplayContend.getCountDownLatch();
// 调用后台接收处理所有的Replay信息 // 调用后台接收处理所有的Replay信息
asyncWaitOctopusMessageResultService.waitFor(agentReplayContend); asyncWaitOctopusMessageResultService.waitFor(agentReplayContend);
//此处存在重大bug,会导致CPU占用飙升
/*CompletableFuture<Void> getAllAgentVersionInfoFuture = waitCollectAllAgentVersionInfo(
result,
currentTime,
countDownLatch
);*/
boolean isAllHealthyAgentReport = false; boolean isAllHealthyAgentReport = false;
try { try {
// 超时等待5秒钟, 或者所有的Agent均已经完成上报 // 超时等待5秒钟, 或者所有的Agent均已经完成上报

View File

@@ -7,7 +7,6 @@ JAVA_OPTS="-Xms128m -Xmx512m -Ddebug=false -Dfile.encoding=utf-8 --spring.profi
DependLibFiles=( DependLibFiles=(
wdd-lib-file.sh wdd-lib-file.sh
wdd-lib-log.sh wdd-lib-log.sh
wdd-lib-os.sh
wdd-lib-env.sh wdd-lib-env.sh
wdd-lib-sys.sh wdd-lib-sys.sh
) )
@@ -254,9 +253,6 @@ DownloadAllFile() {
colorEcho $BLUE "start to download octopus agent !" colorEcho $BLUE "start to download octopus agent !"
# check for latest version # check for latest version
# download the lasted jar # download the lasted jar
cd $OctopusAgentPath
colorEcho $BLUE "start to load wdd-lib-os.sh"
. ./lib/wdd-lib-os.sh
CheckAndDownloadLatestVersion CheckAndDownloadLatestVersion
FunctionSuccess FunctionSuccess
@@ -264,6 +260,34 @@ DownloadAllFile() {
} }
CheckAndDownloadLatestVersion() {
log "checking for the latest version"
local latestVersion=$(curl $OctopusAgentUrl | grep -v h1 | grep "a href=" | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1)
log ""
log "octopus agent latest version is => [ $latestVersion ]"
log ""
rm -rf /octopus-agent/octopus-agent*
cd /octopus-agent
log "start to download the latest version !"
# Agent二进制文件的命名规则为 octopus-agent_linux_amd64_<version>
local latestAgentVersion="octopus-agent_linux_${LinuxRelease}_${latestVersion}"
wget -q "$OctopusAgentUrl$latestAgentVersion"
cp "$latestAgentVersion" octopus-agent
chmod +x octopus-agent
log ""
log ""
log "---------------- ls the /octopus-agent ----------------------"
ls /octopus-agent/ | grep octopus-agent
log "----------------------------------------------"
}
####################################### #######################################
# description # description
# Globals: # Globals:
@@ -355,8 +379,7 @@ SyslogIdentifier=octopus-agent
User=root User=root
Type=simple Type=simple
WorkingDirectory=/octopus-agent WorkingDirectory=/octopus-agent
EnvironmentFile=/etc/environment.d/octopus-agent.conf ExecStart=/octpus-agent/octopus-agent -agentInfoConf=/octpus-agent/octopus-agent.conf
ExecStart=java -jar /octopus-agent/agent.jar ${JAVA_OPTS}
ExecStop=/bin/kill -15 \$MAINPID ExecStop=/bin/kill -15 \$MAINPID
[Install] [Install]
@@ -609,6 +632,7 @@ CleanOldOctopusAgent() {
agentPid=$(ps -ef | grep -v "color="| grep -c "octopus-agent") agentPid=$(ps -ef | grep -v "color="| grep -c "octopus-agent")
if [[ $agentPid -gt 0 ]]; then if [[ $agentPid -gt 0 ]]; then
colorEcho $BLUE "old agent existed ! start to kill"
colorEcho $BLUE "old agent existed ! start to kill" colorEcho $BLUE "old agent existed ! start to kill"
systemctl stop octopus-agent systemctl stop octopus-agent
sleep 2 sleep 2
@@ -636,8 +660,6 @@ main() {
CommonToolInstall CommonToolInstall
InstallJDKPackage 11
# 不能使用下面的内容,会导致命令行执行的时候,本更新进程也会被杀死 # 不能使用下面的内容,会导致命令行执行的时候,本更新进程也会被杀死
# CleanOldOctopusAgent # CleanOldOctopusAgent

View File

@@ -146,7 +146,6 @@ GetAgentLatestVersion(){
} }
####################################### #######################################
# description # description
# Globals: # Globals:
@@ -319,31 +318,30 @@ if [[ $(cat /etc/hostname | cut -d"-" -f 3 | grep -c '^[0-9][0-9]') -gt 0 ]]; th
else else
machineNumber=99 machineNumber=99
fi fi
cat >/etc/environment.d/octopus-agent.conf <<EOF #cat >/etc/environment.d/octopus-agent.conf <<EOF
serverName=${city}-${hostArch}-${machineNumber} cat >/octopus-agent/octopus-agent.conf <<EOF
serverIpPbV4=$public_ipv4 serverName: ${city}-${hostArch}-${machineNumber}
serverIpInV4= serverIpPbV4: $public_ipv4
serverIpPbV6=$public_ipv6 serverIpInV4:
serverIpInV6= serverIpPbV6: $public_ipv6
location="$city $region $country" serverIpInV6:
provider=$org location: "$city $region $country"
managePort=$(netstat -ntulp | grep sshd | grep -w tcp | awk '{print$4}' | cut -d":" -f2) provider: $org
cpuCore="$cores @ $freq MHz" managePort: $(netstat -ntulp | grep sshd | grep -w tcp | awk '{print$4}' | cut -d":" -f2)
cpuBrand="$cpuName" cpuCore: "$cores @ $freq MHz"
memoryTotal=$tram cpuBrand: "$cpuName"
diskTotal=$disk_total_size memoryTotal: $tram
diskUsage=$disk_used_size diskTotal: $disk_total_size
archInfo="$arch ($lbit Bit)" diskUsage: $disk_used_size
osInfo="$opsy" archInfo: "$arch ($lbit Bit)"
osKernelInfo=$kern osInfo: "$opsy"
tcpControl=$tcpctrl osKernelInfo: $kern
virtualization=$virt tcpControl: $tcpctrl
ioSpeed="$ioavg MB/s" virtualization: $virt
machineId=$(cat /etc/machine-id) ioSpeed: "$ioavg MB/s"
agentVersion=$(ls /octopus-agent | grep "octopus-agent" | cut -d "-" -f3- | cut -d"." -f1) machineId: $(cat /etc/machine-id)
agentVersion: $(ls /octopus-agent | grep "octopus-agent" | cut -d "-" -f4-)
EOF EOF
log "env collect complete!" log "agent server info has collect complete!"
source /etc/environment log "file is => /octopus-agent/octopus-agent.conf"
env

View File

@@ -5,7 +5,7 @@
# shellcheck disable=SC1091 # shellcheck disable=SC1091
# Load Generic Libraries # Load Generic Libraries
. /octopus-agent/shell/lib/wdd-lib-log.shwdd-lib-log.sh . /octopus-agent/shell/lib/wdd-lib-log.sh
# Functions # Functions

View File

@@ -1,80 +0,0 @@
#!/bin/bash
. /octopus-agent/shell/lib/wdd-lib-log.sh
OctopusAgentUrl=https://happybirthday.107421.xyz/octopus-agent/
OctopusAgentPath=/octopus-agent/shell
DependLibFiles=(
wdd-lib-file.sh
wdd-lib-log.sh
wdd-lib-os.sh
wdd-lib-env.sh
wdd-lib-sys.sh
)
CheckAndDownloadLatestVersion() {
log "checking for the latest version"
local latestVersion=$(curl $OctopusAgentUrl | grep -v h1 | grep "a href=" | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1)
log ""
log "octopus agent latest version is => [ $latestVersion ]"
log ""
rm -rf /octopus-agent/*.jar
cd /octopus-agent
log "start to download the latest version !"
wget -q "$OctopusAgentUrl$latestVersion"
cp "$latestVersion" agent.jar
log ""
log ""
log "---------------- ls the /octopus-agent ----------------------"
ls /octopus-agent/ | grep jar
log "----------------------------------------------"
}
#######################################
# description
# Globals:
# BLUE
# DependLibFiles
# OctopusAgentPath
# RED
# RepoSourcePath
# libfile
# Arguments:
# None
#######################################
DownloadAllFile() {
FunctionStart
warn "[CLEAN_UP] clean the old octopus agent staff !"
rm -rf $OctopusAgentPath/lib
rm -rf $OctopusAgentPath/
mkdir -p $OctopusAgentPath
mkdir -p $OctopusAgentPath/lib
echo "start to download all needed lib shell"
for libfile in ${DependLibFiles[*]}; do
log "lib file is $libfile"
wget "$RepoSourcePath/lib/$libfile" -qO $OctopusAgentPath/lib/$libfile
FunctionSuccess
done
colorEcho $BLUE "start to download octopus agent !"
# check for latest version
# download the lasted jar
cd $OctopusAgentPath
CheckAndDownloadLatestVersion
FunctionSuccess
FunctionEnd
}