[ 项目 ] 修改CI CD流程
This commit is contained in:
@@ -14,7 +14,9 @@ func main() {
|
||||
|
||||
// 解析命令行参数
|
||||
var version string
|
||||
var agentInfoConf string
|
||||
flag.StringVar(&version, "version", "", "config file version")
|
||||
flag.StringVar(&agentInfoConf, "agentInfoConf", "", "agent server info conf file")
|
||||
flag.Parse()
|
||||
// 读取对应版本的配置文件
|
||||
filename := fmt.Sprintf("octopus-agent-%s.yaml", version)
|
||||
|
||||
@@ -78,18 +78,9 @@ public class OctopusAgentServiceImpl implements OctopusAgentService {
|
||||
|
||||
CountDownLatch countDownLatch = agentReplayContend.getCountDownLatch();
|
||||
|
||||
|
||||
// 调用后台接收处理所有的Replay信息
|
||||
asyncWaitOctopusMessageResultService.waitFor(agentReplayContend);
|
||||
|
||||
//此处存在重大bug,会导致CPU占用飙升
|
||||
/*CompletableFuture<Void> getAllAgentVersionInfoFuture = waitCollectAllAgentVersionInfo(
|
||||
result,
|
||||
currentTime,
|
||||
countDownLatch
|
||||
);*/
|
||||
|
||||
|
||||
boolean isAllHealthyAgentReport = false;
|
||||
try {
|
||||
// 超时等待5秒钟, 或者所有的Agent均已经完成上报
|
||||
|
||||
@@ -7,7 +7,6 @@ JAVA_OPTS="-Xms128m -Xmx512m -Ddebug=false -Dfile.encoding=utf-8 --spring.profi
|
||||
DependLibFiles=(
|
||||
wdd-lib-file.sh
|
||||
wdd-lib-log.sh
|
||||
wdd-lib-os.sh
|
||||
wdd-lib-env.sh
|
||||
wdd-lib-sys.sh
|
||||
)
|
||||
@@ -254,9 +253,6 @@ DownloadAllFile() {
|
||||
colorEcho $BLUE "start to download octopus agent !"
|
||||
# check for latest version
|
||||
# download the lasted jar
|
||||
cd $OctopusAgentPath
|
||||
colorEcho $BLUE "start to load wdd-lib-os.sh"
|
||||
. ./lib/wdd-lib-os.sh
|
||||
CheckAndDownloadLatestVersion
|
||||
|
||||
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
|
||||
# Globals:
|
||||
@@ -355,8 +379,7 @@ SyslogIdentifier=octopus-agent
|
||||
User=root
|
||||
Type=simple
|
||||
WorkingDirectory=/octopus-agent
|
||||
EnvironmentFile=/etc/environment.d/octopus-agent.conf
|
||||
ExecStart=java -jar /octopus-agent/agent.jar ${JAVA_OPTS}
|
||||
ExecStart=/octpus-agent/octopus-agent -agentInfoConf=/octpus-agent/octopus-agent.conf
|
||||
ExecStop=/bin/kill -15 \$MAINPID
|
||||
|
||||
[Install]
|
||||
@@ -609,6 +632,7 @@ CleanOldOctopusAgent() {
|
||||
|
||||
agentPid=$(ps -ef | grep -v "color="| grep -c "octopus-agent")
|
||||
if [[ $agentPid -gt 0 ]]; then
|
||||
colorEcho $BLUE "old agent existed ! start to kill"
|
||||
colorEcho $BLUE "old agent existed ! start to kill"
|
||||
systemctl stop octopus-agent
|
||||
sleep 2
|
||||
@@ -636,8 +660,6 @@ main() {
|
||||
|
||||
CommonToolInstall
|
||||
|
||||
InstallJDKPackage 11
|
||||
|
||||
# 不能使用下面的内容,会导致命令行执行的时候,本更新进程也会被杀死
|
||||
# CleanOldOctopusAgent
|
||||
|
||||
|
||||
@@ -140,13 +140,12 @@ StartIOTest() {
|
||||
|
||||
}
|
||||
|
||||
GetAgentLatestVersion(){
|
||||
GetAgentLatestVersion() {
|
||||
|
||||
ls /octopus-agent | grep "octopus-agent" | cut -d "-" -f3- | cut -d"." -f1
|
||||
|
||||
}
|
||||
|
||||
|
||||
#######################################
|
||||
# description
|
||||
# Globals:
|
||||
@@ -319,31 +318,30 @@ if [[ $(cat /etc/hostname | cut -d"-" -f 3 | grep -c '^[0-9][0-9]') -gt 0 ]]; th
|
||||
else
|
||||
machineNumber=99
|
||||
fi
|
||||
cat >/etc/environment.d/octopus-agent.conf <<EOF
|
||||
serverName=${city}-${hostArch}-${machineNumber}
|
||||
serverIpPbV4=$public_ipv4
|
||||
serverIpInV4=
|
||||
serverIpPbV6=$public_ipv6
|
||||
serverIpInV6=
|
||||
location="$city $region $country"
|
||||
provider=$org
|
||||
managePort=$(netstat -ntulp | grep sshd | grep -w tcp | awk '{print$4}' | cut -d":" -f2)
|
||||
cpuCore="$cores @ $freq MHz"
|
||||
cpuBrand="$cpuName"
|
||||
memoryTotal=$tram
|
||||
diskTotal=$disk_total_size
|
||||
diskUsage=$disk_used_size
|
||||
archInfo="$arch ($lbit Bit)"
|
||||
osInfo="$opsy"
|
||||
osKernelInfo=$kern
|
||||
tcpControl=$tcpctrl
|
||||
virtualization=$virt
|
||||
ioSpeed="$ioavg MB/s"
|
||||
machineId=$(cat /etc/machine-id)
|
||||
agentVersion=$(ls /octopus-agent | grep "octopus-agent" | cut -d "-" -f3- | cut -d"." -f1)
|
||||
#cat >/etc/environment.d/octopus-agent.conf <<EOF
|
||||
cat >/octopus-agent/octopus-agent.conf <<EOF
|
||||
serverName: ${city}-${hostArch}-${machineNumber}
|
||||
serverIpPbV4: $public_ipv4
|
||||
serverIpInV4:
|
||||
serverIpPbV6: $public_ipv6
|
||||
serverIpInV6:
|
||||
location: "$city $region $country"
|
||||
provider: $org
|
||||
managePort: $(netstat -ntulp | grep sshd | grep -w tcp | awk '{print$4}' | cut -d":" -f2)
|
||||
cpuCore: "$cores @ $freq MHz"
|
||||
cpuBrand: "$cpuName"
|
||||
memoryTotal: $tram
|
||||
diskTotal: $disk_total_size
|
||||
diskUsage: $disk_used_size
|
||||
archInfo: "$arch ($lbit Bit)"
|
||||
osInfo: "$opsy"
|
||||
osKernelInfo: $kern
|
||||
tcpControl: $tcpctrl
|
||||
virtualization: $virt
|
||||
ioSpeed: "$ioavg MB/s"
|
||||
machineId: $(cat /etc/machine-id)
|
||||
agentVersion: $(ls /octopus-agent | grep "octopus-agent" | cut -d "-" -f4-)
|
||||
EOF
|
||||
|
||||
log "env collect complete!"
|
||||
source /etc/environment
|
||||
|
||||
env
|
||||
log "agent server info has collect complete!"
|
||||
log "file is => /octopus-agent/octopus-agent.conf"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# shellcheck disable=SC1091
|
||||
|
||||
# Load Generic Libraries
|
||||
. /octopus-agent/shell/lib/wdd-lib-log.shwdd-lib-log.sh
|
||||
. /octopus-agent/shell/lib/wdd-lib-log.sh
|
||||
|
||||
# Functions
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user