Skip to content

Commit

Permalink
feat: remove buildPkgVersion, using auto adapating
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglsir committed Jul 5, 2021
1 parent 947f91e commit b18fa0d
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 48 deletions.
1 change: 0 additions & 1 deletion script/deploy/deploy-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ currDate=$(date -d today +"%Y-%m-%d_%H%M%S")
[ -z "$apacheMvnLocalRepoDir" ] && export apacheMvnLocalRepoDir="$HOME/.m2/repository/"
# Maven build.
[ -z "$buildPkgType" ] && export buildPkgType="mvnAssTar" # Options: mvnAssTar|springExecJar
[ -z "$buildPkgVersion" ] && export buildPkgVersion="master"
# Deploy.
[ -z "$runtimeMode" ] && export runtimeMode="cluster" # Options: standalone|cluster
[ -z "$deployAppBaseDir" ] && export deployAppBaseDir="/opt/apps/ecm"
Expand Down
11 changes: 10 additions & 1 deletion script/deploy/deploy-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,14 @@ function downloadFile() {
fi
}
# Gets frontend project build version.
function getFrontendBuildVersion() {
local fProjectDir="$currDir/$gitXCloudDoPaaSViewProjectName"
# Extract npm project version from package.json
local fBuildVersion=$(cat "$fProjectDir/package.json"|grep -E "\"version\":(\s)*"|awk -F ':' '{print $2}'|sed -r "s/\"//g"|sed 's/,//g'|sed 's/ //g')
echo "$fBuildVersion"
}
# Make nginx conf of dopaas.
# for example:
# nodeArr=("10.0.0.100" "10.0.0.200")
Expand All @@ -737,6 +745,7 @@ function makeNginxConf() {
logErr "Invalid config runtime mode: $runtimeMode"; exit -1
fi
local deployBuildModulesSize=${#deployBuildModules[@]}
local fBuildVersion=$(getFrontendBuildVersion)
if [ $deployBuildModulesSize -gt 0 ]; then
local configStr="
# Auto Generated by DoPaaS deployer.
Expand Down Expand Up @@ -773,7 +782,7 @@ server {
server_name dopaas.wl4g.${springProfilesActive};
include /etc/nginx/default.d/*.conf;
location / {
root /usr/share/nginx/html/xcloud-dopaas-view-package/xcloud-dopaas-view-master-bin;
root /usr/share/nginx/html/xcloud-dopaas-view-package/xcloud-dopaas-view-${fBuildVersion}-bin;
index index.html;
}
}
Expand Down
74 changes: 40 additions & 34 deletions script/deploy/deploy-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,68 +24,74 @@
export springProfilesActive='fat' # options: dev|fat|uat|pro

# Deploy for standalone mode.(And cluster mode are mutually exclusive)
export STANDALONE_DOPAAS_DB_URL='jdbc:mysql://localhost:3306/dopaas_standalone?useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&autoReconnect=true'
export STANDALONE_DOPAAS_DB_URL='jdbc:mysql://owner-node2:3306/dopaas_standalone?useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&autoReconnect=true'
export STANDALONE_DOPAAS_DB_USER='dopaas'
export STANDALONE_DOPAAS_DB_PASSWD='12345678'
export STANDALONE_DOPAAS_REDIS_PASSWD='12345678'
export STANDALONE_DOPAAS_REDIS_NODES='localhost:6379,localhost:6380,localhost:6381,localhost:7379,localhost:7380,localhost:7381'
export STANDALONE_DOPAAS_REDIS_PASSWD='zzx!@#$%'
export STANDALONE_DOPAAS_REDIS_NODES='owner-node2:6379,owner-node2:6380,owner-node2:6381,owner-node2:7379,owner-node2:7380,owner-node2:7381'

# Deploy for cluster mode.(And standalone mode are mutually exclusive)
export IAM_DB_URL='jdbc:mysql://localhost:3306/dopaas_iam?useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&autoReconnect=true'
export IAM_DB_URL='jdbc:mysql://owner-node2:3306/dopaas_iam?useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&autoReconnect=true'
export IAM_DB_USER='dopaas'
export IAM_DB_PASSWD='12345678'
export IAM_REDIS_PASSWD='12345678'
export IAM_REDIS_NODES='localhost:6379,localhost:6380,localhost:6381,localhost:7379,localhost:7380,localhost:7381'
export CMDB_DOPAAS_DB_URL='jdbc:mysql://localhost:3306/dopaas_cmdb?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export IAM_REDIS_PASSWD='zzx!@#$%'
export IAM_REDIS_NODES='owner-node2:6379,owner-node2:6380,owner-node2:6381,owner-node2:7379,owner-node2:7380,owner-node2:7381'
export CMDB_DOPAAS_DB_URL='jdbc:mysql://owner-node2:3306/dopaas_cmdb?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export CMDB_DOPAAS_DB_USER='dopaas'
export CMDB_DOPAAS_DB_PASSWD='12345678'
export CMDB_DOPAAS_REDIS_PASSWD='12345678'
export CMDB_DOPAAS_REDIS_NODES='localhost:6379,localhost:6380,localhost:6381,localhost:7379,localhost:7380,localhost:7381'
export UCI_DOPAAS_DB_URL='jdbc:mysql://localhost:3306/dopaas_uci?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export CMDB_DOPAAS_REDIS_PASSWD='zzx!@#$%'
export CMDB_DOPAAS_REDIS_NODES='owner-node2:6379,owner-node2:6380,owner-node2:6381,owner-node2:7379,owner-node2:7380,owner-node2:7381'
export UCI_DOPAAS_DB_URL='jdbc:mysql://owner-node2:3306/dopaas_uci?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export UCI_DOPAAS_DB_USER='dopaas'
export UCI_DOPAAS_DB_PASSWD='12345678'
export UCI_DOPAAS_REDIS_PASSWD='12345678'
export UCI_DOPAAS_REDIS_NODES='localhost:6379,localhost:6380,localhost:6381,localhost:7379,localhost:7380,localhost:7381'
export UDM_DOPAAS_DB_URL='jdbc:mysql://localhost:3306/dopaas_udm?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export UCI_DOPAAS_REDIS_PASSWD='zzx!@#$%'
export UCI_DOPAAS_REDIS_NODES='owner-node2:6379,owner-node2:6380,owner-node2:6381,owner-node2:7379,owner-node2:7380,owner-node2:7381'
export UDM_DOPAAS_DB_URL='jdbc:mysql://owner-node2:3306/dopaas_udm?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export UDM_DOPAAS_DB_USER='dopaas'
export UDM_DOPAAS_DB_PASSWD='12345678'
export UDM_DOPAAS_REDIS_PASSWD='12345678'
export UDM_DOPAAS_REDIS_NODES='localhost:6379,localhost:6380,localhost:6381,localhost:7379,localhost:7380,localhost:7381'
export HOME_DOPAAS_DB_URL='jdbc:mysql://localhost:3306/dopaas_home?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export UDM_DOPAAS_REDIS_PASSWD='zzx!@#$%'
export UDM_DOPAAS_REDIS_NODES='owner-node2:6379,owner-node2:6380,owner-node2:6381,owner-node2:7379,owner-node2:7380,owner-node2:7381'
export HOME_DOPAAS_DB_URL='jdbc:mysql://owner-node2:3306/dopaas_home?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export HOME_DOPAAS_DB_USER='dopaas'
export HOME_DOPAAS_DB_PASSWD='12345678'
export HOME_DOPAAS_REDIS_PASSWD='12345678'
export HOME_DOPAAS_REDIS_NODES='localhost:6379,localhost:6380,localhost:6381,localhost:7379,localhost:7380,localhost:7381'
export LCDP_DOPAAS_DB_URL='jdbc:mysql://localhost:3306/dopaas_lcdp?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export HOME_DOPAAS_REDIS_PASSWD='zzx!@#$%'
export HOME_DOPAAS_REDIS_NODES='owner-node2:6379,owner-node2:6380,owner-node2:6381,owner-node2:7379,owner-node2:7380,owner-node2:7381'
export LCDP_DOPAAS_DB_URL='jdbc:mysql://owner-node2:3306/dopaas_lcdp?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export LCDP_DOPAAS_DB_USER='dopaas'
export LCDP_DOPAAS_DB_PASSWD='12345678'
export LCDP_DOPAAS_REDIS_PASSWD='12345678'
export LCDP_DOPAAS_REDIS_NODES='localhost:6379,localhost:6380,localhost:6381,localhost:7379,localhost:7380,localhost:7381'
export UCM_DOPAAS_DB_URL='jdbc:mysql://localhost:3306/dopaas_ucm?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export LCDP_DOPAAS_REDIS_PASSWD='zzx!@#$%'
export LCDP_DOPAAS_REDIS_NODES='owner-node2:6379,owner-node2:6380,owner-node2:6381,owner-node2:7379,owner-node2:7380,owner-node2:7381'
export UCM_DOPAAS_DB_URL='jdbc:mysql://owner-node2:3306/dopaas_ucm?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export UCM_DOPAAS_DB_USER='dopaas'
export UCM_DOPAAS_DB_PASSWD='12345678'
export UCM_DOPAAS_REDIS_PASSWD='12345678'
export UCM_DOPAAS_REDIS_NODES='localhost:6379,localhost:6380,localhost:6381,localhost:7379,localhost:7380,localhost:7381'
export UDS_DOPAAS_DB_URL='jdbc:mysql://localhost:3306/dopaas_uds?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export UCM_DOPAAS_REDIS_PASSWD='zzx!@#$%'
export UCM_DOPAAS_REDIS_NODES='owner-node2:6379,owner-node2:6380,owner-node2:6381,owner-node2:7379,owner-node2:7380,owner-node2:7381'
export UDS_DOPAAS_DB_URL='jdbc:mysql://owner-node2:3306/dopaas_uds?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export UDS_DOPAAS_DB_USER='dopaas'
export UDS_DOPAAS_DB_PASSWD='12345678'
export UDS_DOPAAS_REDIS_PASSWD='12345678'
export UDS_DOPAAS_REDIS_NODES='localhost:6379,localhost:6380,localhost:6381,localhost:7379,localhost:7380,localhost:7381'
export UMC_DOPAAS_DB_URL='jdbc:mysql://localhost:3306/dopaas_umc?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export UDS_DOPAAS_REDIS_PASSWD='zzx!@#$%'
export UDS_DOPAAS_REDIS_NODES='owner-node2:6379,owner-node2:6380,owner-node2:6381,owner-node2:7379,owner-node2:7380,owner-node2:7381'
export UMC_DOPAAS_DB_URL='jdbc:mysql://owner-node2:3306/dopaas_umc?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export UMC_DOPAAS_DB_USER='dopaas'
export UMC_DOPAAS_DB_PASSWD='12345678'
export UMC_DOPAAS_REDIS_PASSWD='12345678'
export UMC_DOPAAS_REDIS_NODES='localhost:6379,localhost:6380,localhost:6381,localhost:7379,localhost:7380,localhost:7381'
export URM_DOPAAS_DB_URL='jdbc:mysql://localhost:3306/dopaas_urm?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export UMC_DOPAAS_REDIS_PASSWD='zzx!@#$%'
export UMC_DOPAAS_REDIS_NODES='owner-node2:6379,owner-node2:6380,owner-node2:6381,owner-node2:7379,owner-node2:7380,owner-node2:7381'
export URM_DOPAAS_DB_URL='jdbc:mysql://owner-node2:3306/dopaas_urm?useunicode=true&servertimezone=asia/shanghai&characterencoding=utf-8&usessl=false&allowmultiqueries=true&autoreconnect=true'
export URM_DOPAAS_DB_USER='dopaas'
export URM_DOPAAS_DB_PASSWD='12345678'
export URM_DOPAAS_REDIS_PASSWD='12345678'
export URM_DOPAAS_REDIS_NODES='localhost:6379,localhost:6380,localhost:6381,localhost:7379,localhost:7380,localhost:7381'
export URM_DOPAAS_REDIS_PASSWD='zzx!@#$%'
export URM_DOPAAS_REDIS_NODES='owner-node2:6379,owner-node2:6380,owner-node2:6381,owner-node2:7379,owner-node2:7380,owner-node2:7381'

# Others deployer configuration.
#export deployFrontendSkip=true # options: true|false
#export deployDebug=true # options: true|false

#export gitBaseUri='https://gitee.com/wl4g' # options: https://gitee.com/wl4g | https://github.com/wl4g

#export gitDefaultBranch=master # e.g: master | 2.0.0-RC3-jobs
#export gitComponentBranch="${gitDefaultBranch}"
#export gitIamBranch="${gitDefaultBranch}"
#export gitDoPaaSBranch="${gitDefaultBranch}"
#export gitDoPaaSViewBranch="${gitDefaultBranch}"

#export buildForcedOnPullUpToDate=true # options: true|false
#export buildPkgVersion="master"
28 changes: 16 additions & 12 deletions script/deploy/deploy-host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ buildFilePath=$buildFilePath, buildFileName=$buildFileName, cmdRestart=$cmdResta
elif [[ "$buildPkgType" == "springExecJar" ]]; then
log "[$appName/standalone/local] Copying $buildFilePath to $appInstallDir/ ..."
unalias cp >/dev/null 2>&1
cp -Rf ${appName}-${buildPkgVersion}-bin.jar $appInstallDir/
cp -Rf ${appName}-*-bin.jar $appInstallDir/
else
logErr "[$appName/standalone/local] Invalid config buildPkgType: $buildPkgType"; exit -1
fi
Expand Down Expand Up @@ -272,12 +272,14 @@ function doDeployBackendApp() {
logErr "Failed to deploy, buildTargetDir is required! all args: '$@'"; exit -1
fi
if [ "$buildPkgType" == "mvnAssTar" ]; then
local buildFileName=$(ls -a "$buildTargetDir"|grep -E "*-${buildPkgVersion}-bin.tar")
local buildFileName=$(ls -a "$buildTargetDir"|grep -E "*-*-bin.tar")
local buildVersion=$(ls -a "$buildTargetDir"|grep -E "*-*-bin.tar"|awk -F '-' '{print $3}')
elif [ "$buildPkgType" == "springExecJar" ]; then
local buildFileName=$(ls -a "$buildTargetDir"|grep -E "*-${buildPkgVersion}-bin.jar")
local buildFileName=$(ls -a "$buildTargetDir"|grep -E "*-*-bin.jar")
local buildVersion=$(ls -a "$buildTargetDir"|grep -E "*-*-bin.jar"|awk -F '-' '{print $3}')
fi
if [ -z "$buildFileName" ]; then
logErr "Failed to deploy, buildFileName is required! all args: '$@'"; exit -1
if [[ -z "$buildFileName" || -z "$buildVersion" ]]; then
logErr "Failed to deploy, buildFileName/buildVersion is required! all args: '$@'"; exit -1
fi
local cmdRestart="sudo chmod -R 755 $deployAppBaseDir && [ -n $(command -v systemctl) ] && sudo systemctl restart ${appName} || su - $appName -c \"/etc/init.d/${appName}.service restart\""

Expand Down Expand Up @@ -328,8 +330,8 @@ function deployBackendAll() {
local appName=$(echo "$buildModule"|awk -F ',' '{print $1}')
globalDeployStatsMsg="${globalDeployStatsMsg}\n
[${appName}]:
Install Home: ${deployAppBaseDir}/${appName}-package/${appName}-${buildPkgVersion}-bin/
Config Dir: ${deployAppBaseDir}/${appName}-package/${appName}-${buildPkgVersion}-bin/conf/
Install Home: ${deployAppBaseDir}/${appName}-package/${appName}-*-bin/
Config Dir: ${deployAppBaseDir}/${appName}-package/${appName}-*-bin/conf/
Profiles Active: ${springProfilesActive}
PID File: /mnt/disk1/${appName}/${appName}.pid
Restart Command: sudo systemctl restart ${appName} or su - ${appName} -c \"/etc/init.d/${appName}.service restart\"
Expand Down Expand Up @@ -448,8 +450,8 @@ function deployEurekaServers() {
# Add eureka-server deployed summary.
globalDeployStatsMsg="${globalDeployStatsMsg}\n
[${appName}]:
Install Home: ${deployAppBaseDir}/${appName}-package/${appName}-${buildPkgVersion}-bin/
Config Dir: ${deployAppBaseDir}/${appName}-package/${appName}-${buildPkgVersion}-bin/conf/
Install Home: ${deployAppBaseDir}/${appName}-package/${appName}-*-bin/
Config Dir: ${deployAppBaseDir}/${appName}-package/${appName}-*-bin/conf/
Profiles Active: ${springProfilesActive}
PID File: /mnt/disk1/${appName}/${appName}.pid
Restart Command: sudo systemctl restart $appName or /etc/init.d/$appName.service restart
Expand Down Expand Up @@ -483,8 +485,8 @@ function deployEurekaServers() {
# Add eureka-server deployed summary.
globalDeployStatsMsg="${globalDeployStatsMsg}\n
[${appName}]:
Install Home: ${deployAppBaseDir}/${appName}-package/${appName}-${buildPkgVersion}-bin/
Config Dir: ${deployAppBaseDir}/${appName}-package/${appName}-${buildPkgVersion}-bin/conf/
Install Home: ${deployAppBaseDir}/${appName}-package/${appName}-*-bin/
Config Dir: ${deployAppBaseDir}/${appName}-package/${appName}-*-bin/conf/
Profiles Active: ${springProfilesActive}
PID File: /mnt/disk1/${appName}/${appName}.pid
Restart Command: sudo systemctl restart $appName or /etc/init.d/$appName.service restart
Expand Down Expand Up @@ -697,8 +699,10 @@ function deployFrontendAll() {
fi
# Deploy frontend.
local deployFrontendDir="${appInstallDir}/${appName}-${buildPkgVersion}-bin"
local fProjectDir="$currDir/$gitXCloudDoPaaSViewProjectName"
# Extract npm project version from package.json
local fBuildVersion=$(getFrontendBuildVersion)
local deployFrontendDir="${appInstallDir}/${appName}-${fBuildVersion}-bin"
# Check build dist files.
if [[ ! -d "$fProjectDir" || "$(ls $fProjectDir/dist/*|wc -l)" -le 0 ]]; then
logErr "Cannot reading frontend build assets, because dist directory not exists!"; exit -1
Expand Down

0 comments on commit b18fa0d

Please sign in to comment.