From b3f09e70d40eeb7e6803b5bb0ce126ac00a3d4d6 Mon Sep 17 00:00:00 2001 From: zhoucg Date: Mon, 29 May 2023 14:54:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0ztf=20test=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=20=E6=96=87=E4=BB=B6=E7=B3=BB=E7=BB=9F/=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=8F=91=E5=B8=83=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hua_wei_yun/04wms-ztf-test.sh | 282 ------------------------------ hua_wei_yun/05wms-ztf-test.sh | 282 ++++++++++++++++++++++++++++++ hua_wei_yun/06wms-ztf-filemanager-test.sh | 202 +++++++++++++++++++++ hua_wei_yun/07wms-ztf-print-test.sh | 202 +++++++++++++++++++++ 4 files changed, 686 insertions(+), 282 deletions(-) delete mode 100644 hua_wei_yun/04wms-ztf-test.sh create mode 100644 hua_wei_yun/05wms-ztf-test.sh create mode 100644 hua_wei_yun/06wms-ztf-filemanager-test.sh create mode 100644 hua_wei_yun/07wms-ztf-print-test.sh diff --git a/hua_wei_yun/04wms-ztf-test.sh b/hua_wei_yun/04wms-ztf-test.sh deleted file mode 100644 index 5f3f66a..0000000 --- a/hua_wei_yun/04wms-ztf-test.sh +++ /dev/null @@ -1,282 +0,0 @@ -#!/bin/bash -#set -x -set -e - -codePath=/home/www/deploy/wms8_ztf_2 -gitUrlArr=( - "http://git.yvanui.com/jztd/wms.git" - "http://git.yvanui.com/jztd/wms-ui-pc.git" - "http://git.yvanui.com/jztd/wms-ui-mobile.git" - "http://git.yvanui.com/lizhiwei/yvan-framework.git" -) - -branchArr=( - "master" - "master" - "master" - "8.4" -) -positionArr=( - "." - "wms-ui-pc" - "wms-ui-mobile" - "yvan-framework" -) -# 是否需要构建,-1:自动;0:不需要;1:需要 -needBuild=( -"1" -"1" -"1" -"1" -) - -echoPrefix="\033[36m+" -echoSuffix="\033[0m" - -# 强制覆盖本地的代码 git fetch --all && git reset --hard origin/master -isChange="1" # 仓库是否发生变化,0:未变化;非0:变化 -pullCode() { - # Usage: pullCode "codePath" "gitUrl" "branch" "position" - path=$1 # 代码保存路径 - gitUrl=$2 # git仓库地址 - branch=${3:-"master"} # git分支 - position=${4:-""} # 使用“.”clone到当前文件夹 - isChange="1" - # 创建文件夹 - if [ ! -d "$path" ]; then - echo -e "$echoPrefix 请检查服务器是否正确,再执行: mkdir -p $path $echoSuffix" - exit - fi - - # git clone - echo -e "$echoPrefix cd $path $echoSuffix" - cd $path - if [ "`ls -A $path`" == "" ] || [ ! -d "$path/$position" ] || [ "`ls -A $path/$position`" = "" ]; then - echo -e "$echoPrefix git clone $gitUrl $position $echoSuffix" - git clone $gitUrl $position - isChange="2" - fi - - # 进入文件夹,切换分支,git pull - if [ "$position" != "" ]; then - echo -e "$echoPrefix cd $position $echoSuffix" - cd $position - fi - echo -e "$echoPrefix git checkout $branch $echoSuffix" - git checkout $branch - echo -e "$echoPrefix git checkout . $echoSuffix" - git checkout . - echo -e "$echoPrefix git pull $echoSuffix" - if [ "`git pull`" == "Already up-to-date." ] && [ $isChange == "1" ]; then - isChange="0" - fi - echo "" -} - -buildCode() { - # 构建 wms-ui-pc - if [ "${needBuild[1]}" != "0" ]; then - echo -e "$echoPrefix cd $codePath/wms-ui-pc $echoSuffix" - cd "$codePath/wms-ui-pc" - echo -e "$echoPrefix yarn $echoSuffix" - yarn - echo -e "$echoPrefix yarn link yvan-vue $echoSuffix" - yarn link yvan-vue - echo "" - else - echo "wms-ui-pc 文件未变化" - fi - - # 构建 wms-ui-mobile - if [ "${needBuild[2]}" != "0" ]; then - echo -e "$echoPrefix cd $codePath/wms-ui-mobile $echoSuffix" - cd "$codePath/wms-ui-mobile" - echo -e "$echoPrefix yarn $echoSuffix" - yarn - echo -e "$echoPrefix yarn link yvan-vue-mobile $echoSuffix" - yarn link yvan-vue-mobile - echo "" - else - echo "wms-ui-mobile 文件未变化" - fi - - # 构建 java - echo -e "$echoPrefix cd $codePath $echoSuffix" - cd $codePath - echo -e "$echoPrefix gradle build -x test $echoSuffix" - gradle build -x test - echo "" -} - -logPath=/data/logs/wms8_ztf_2/server.log -dirPath=/home/www/deploy/wms8_ztf_2/wms-modules/wms-system/build/libs/ -serverName=2_wms8_ztf_2 - -cmd=$1 -profiles=${2:-"test"} - -#------------------------------------------------------------------- -JAVA_MEM_OPTS=" -DappName=${serverName} -server -Xmx2g -Xms2g" -DATABASE_OPTS=" -Ddatabase.codeset=ISO-8859-1 -Ddatabase.logging=false" -JAVA_OPTS_EXT=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dapplication.codeset=UTF-8 -Dfile.encoding=UTF-8 -Duser.timezone=Asia/Shanghai" -#------------------------------------------------------------------- - -moveBuildFile() { - # 移动编译后的文件 - echo -e "$echoPrefix cd $dirPath $echoSuffix" - cd $dirPath - echo -e "$echoPrefix rm -rf ../runtime $echoSuffix" - rm -rf ../runtime - echo -e "$echoPrefix cp -r ./ ../runtime $echoSuffix" - cp -r ./ ../runtime - echo "" -} - -startServer() { - pid=$1 - if [ -z $pid ];then - echo -e "$echoPrefix cd $dirPath../runtime/ $echoSuffix" - cd $dirPath../runtime/ - echo -e "$echoPrefix java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./wms-system-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles --server.port=8084 >>/dev/null 2>&1 & $echoSuffix" - java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./wms-system-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles --server.port=8084 >>/dev/null 2>&1 & - echo "$serverName 启动成功!" - else - echo "$serverName 正在运行..." - fi - echo "查看日志: tail -F $logPath -n 100" -} - -stopServer() { - pid=$1 - if [ -z $pid ];then - echo "$serverName 未运行" - else - echo -e "$echoPrefix ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print \$2}' | xargs kill $echoSuffix" - ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}' | xargs kill - echo "$serverName 已停止!" - fi -} - -deployPull() { - for ((idx=0; idx<${#gitUrlArr[@]}; idx++)); do - pullCode $codePath ${gitUrlArr[idx]} ${branchArr[idx]} ${positionArr[idx]} - if [ "${needBuild[idx]}" == "-1" ]; then - needBuild[idx]=$isChange - fi - done - # 设置 require_config.js 前端版本 - # version=$(date +_%Y_%m_%d_%H_%M_%S) - # echo -e "$echoPrefix sed -i 's/_[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}/$version/g' $codePath/public/require_config.js $echoSuffix" - # sed -i "s/_[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}/$version/g" $codePath/public/require_config.js - echo "###--代码更新完成--------------------------------------------------------------------------###" - echo "" -} - -deployServer() { - pid=$1 - deployPull - buildCode - echo "###--代码构建完成--------------------------------------------------------------------------###" - # 重启服务 - if [ ! -z $pid ];then - stopServer $pid - sleep 8s - fi - # 移动编译后的文件 - moveBuildFile - startServer -} - -restartServer() { - pid=$1 - if [ ! -z $pid ];then - stopServer $pid - sleep 3s - fi - moveBuildFile - startServer -} - -logs() { - tail -F $logPath -n 100 -} - -deployYvanUI() { - bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/11yvan-vue.sh) deploy - bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/12yvan-vue-mobile.sh) deploy -} - -startPcUi() { - pid=`ps -ef | grep "${codePath}/wms-ui-pc/node_modules/.bin/vite" | grep -v 'grep' | awk '{print $2}'` - if [ -z $pid ];then - echo "wms-ui-pc 未运行" - else - echo -e "$echoPrefix ps -ef | grep "${codePath}/wms-ui-pc/node_modules/.bin/vite" | grep -v 'grep' | awk '{print \$2}' | xargs kill $echoSuffix" - ps -ef | grep "${codePath}/wms-ui-pc/node_modules/.bin/vite" | grep -v 'grep' | awk '{print $2}' | xargs kill - echo "wms-ui-pc 已停止!" - sleep 3s - fi - echo -e "$echoPrefix cd $codePath/wms-ui-pc $echoSuffix" - cd "$codePath/wms-ui-pc" - echo -e "$echoPrefix nohup yarn run dev >>/dev/null 2>&1 & $echoSuffix" - nohup yarn run dev >>/dev/null 2>&1 & -} - -startMobileUi() { - pid=`ps -ef | grep "${codePath}/wms-ui-mobile/node_modules/.bin/vite" | grep -v 'grep' | awk '{print $2}'` - if [ -z $pid ];then - echo "wms-ui-mobile 未运行" - else - echo -e "$echoPrefix ps -ef | grep "${codePath}/wms-ui-mobile/node_modules/.bin/vite" | grep -v 'grep' | awk '{print \$2}' | xargs kill $echoSuffix" - ps -ef | grep "${codePath}/wms-ui-mobile/node_modules/.bin/vite" | grep -v 'grep' | awk '{print $2}' | xargs kill - echo "wms-ui-mobile 已停止!" - sleep 3s - fi - echo -e "$echoPrefix cd $codePath/wms-ui-mobile $echoSuffix" - cd "$codePath/wms-ui-mobile" - echo -e "$echoPrefix nohup yarn run dev >>/dev/null 2>&1 & $echoSuffix" - nohup yarn run dev >>/dev/null 2>&1 & -} - -pid=`ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}'` -# 操作参数: pull build deploy restart start stop kill log logs startPc startMobile -if [ "$cmd" == "pull" ];then - deployYvanUI - deployPull - if [ -z $pid ];then - echo "$serverName 未运行 | 输入操作参数: pull build deploy restart start stop kill log logs startPc startMobile" - fi -elif [ "$cmd" == "build" ];then - deployYvanUI - deployPull - buildCode - echo "###--代码构建完成--------------------------------------------------------------------------###" -elif [ "$cmd" == "deploy" ];then - deployYvanUI - deployServer $pid - startPcUi - startMobileUi -elif [ "$cmd" == "restart" ];then - restartServer $pid -elif [ "$cmd" == "start" ];then - startServer $pid -elif [ "$cmd" == "stop" ] || [ "$cmd" == "kill" ];then - stopServer $pid -elif [ "$cmd" == "log" ] || [ "$cmd" == "logs" ];then - logs -elif [ "$cmd" == "startPc" ];then - startPcUi -elif [ "$cmd" == "startMobile" ];then - startMobileUi -else - if [ -z $pid ];then - echo "$serverName 未运行 | 输入操作参数: pull build deploy restart start stop kill log logs startPc startMobile" - echo "查看日志: tail -F $logPath -n 100" - else - echo "输入操作参数: pull build deploy restart start stop kill log logs startPc startMobile" - echo "pid=$pid | $serverName 正在运行... | 查看日志: tail -F $logPath -n 100" - fi -fi - -# 中通服-华为云-测试 -# bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/hua_wei_yun/04wms-ztf-test.sh) [cmd profiles] diff --git a/hua_wei_yun/05wms-ztf-test.sh b/hua_wei_yun/05wms-ztf-test.sh new file mode 100644 index 0000000..5f3f66a --- /dev/null +++ b/hua_wei_yun/05wms-ztf-test.sh @@ -0,0 +1,282 @@ +#!/bin/bash +#set -x +set -e + +codePath=/home/www/deploy/wms8_ztf_2 +gitUrlArr=( + "http://git.yvanui.com/jztd/wms.git" + "http://git.yvanui.com/jztd/wms-ui-pc.git" + "http://git.yvanui.com/jztd/wms-ui-mobile.git" + "http://git.yvanui.com/lizhiwei/yvan-framework.git" +) + +branchArr=( + "master" + "master" + "master" + "8.4" +) +positionArr=( + "." + "wms-ui-pc" + "wms-ui-mobile" + "yvan-framework" +) +# 是否需要构建,-1:自动;0:不需要;1:需要 +needBuild=( +"1" +"1" +"1" +"1" +) + +echoPrefix="\033[36m+" +echoSuffix="\033[0m" + +# 强制覆盖本地的代码 git fetch --all && git reset --hard origin/master +isChange="1" # 仓库是否发生变化,0:未变化;非0:变化 +pullCode() { + # Usage: pullCode "codePath" "gitUrl" "branch" "position" + path=$1 # 代码保存路径 + gitUrl=$2 # git仓库地址 + branch=${3:-"master"} # git分支 + position=${4:-""} # 使用“.”clone到当前文件夹 + isChange="1" + # 创建文件夹 + if [ ! -d "$path" ]; then + echo -e "$echoPrefix 请检查服务器是否正确,再执行: mkdir -p $path $echoSuffix" + exit + fi + + # git clone + echo -e "$echoPrefix cd $path $echoSuffix" + cd $path + if [ "`ls -A $path`" == "" ] || [ ! -d "$path/$position" ] || [ "`ls -A $path/$position`" = "" ]; then + echo -e "$echoPrefix git clone $gitUrl $position $echoSuffix" + git clone $gitUrl $position + isChange="2" + fi + + # 进入文件夹,切换分支,git pull + if [ "$position" != "" ]; then + echo -e "$echoPrefix cd $position $echoSuffix" + cd $position + fi + echo -e "$echoPrefix git checkout $branch $echoSuffix" + git checkout $branch + echo -e "$echoPrefix git checkout . $echoSuffix" + git checkout . + echo -e "$echoPrefix git pull $echoSuffix" + if [ "`git pull`" == "Already up-to-date." ] && [ $isChange == "1" ]; then + isChange="0" + fi + echo "" +} + +buildCode() { + # 构建 wms-ui-pc + if [ "${needBuild[1]}" != "0" ]; then + echo -e "$echoPrefix cd $codePath/wms-ui-pc $echoSuffix" + cd "$codePath/wms-ui-pc" + echo -e "$echoPrefix yarn $echoSuffix" + yarn + echo -e "$echoPrefix yarn link yvan-vue $echoSuffix" + yarn link yvan-vue + echo "" + else + echo "wms-ui-pc 文件未变化" + fi + + # 构建 wms-ui-mobile + if [ "${needBuild[2]}" != "0" ]; then + echo -e "$echoPrefix cd $codePath/wms-ui-mobile $echoSuffix" + cd "$codePath/wms-ui-mobile" + echo -e "$echoPrefix yarn $echoSuffix" + yarn + echo -e "$echoPrefix yarn link yvan-vue-mobile $echoSuffix" + yarn link yvan-vue-mobile + echo "" + else + echo "wms-ui-mobile 文件未变化" + fi + + # 构建 java + echo -e "$echoPrefix cd $codePath $echoSuffix" + cd $codePath + echo -e "$echoPrefix gradle build -x test $echoSuffix" + gradle build -x test + echo "" +} + +logPath=/data/logs/wms8_ztf_2/server.log +dirPath=/home/www/deploy/wms8_ztf_2/wms-modules/wms-system/build/libs/ +serverName=2_wms8_ztf_2 + +cmd=$1 +profiles=${2:-"test"} + +#------------------------------------------------------------------- +JAVA_MEM_OPTS=" -DappName=${serverName} -server -Xmx2g -Xms2g" +DATABASE_OPTS=" -Ddatabase.codeset=ISO-8859-1 -Ddatabase.logging=false" +JAVA_OPTS_EXT=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dapplication.codeset=UTF-8 -Dfile.encoding=UTF-8 -Duser.timezone=Asia/Shanghai" +#------------------------------------------------------------------- + +moveBuildFile() { + # 移动编译后的文件 + echo -e "$echoPrefix cd $dirPath $echoSuffix" + cd $dirPath + echo -e "$echoPrefix rm -rf ../runtime $echoSuffix" + rm -rf ../runtime + echo -e "$echoPrefix cp -r ./ ../runtime $echoSuffix" + cp -r ./ ../runtime + echo "" +} + +startServer() { + pid=$1 + if [ -z $pid ];then + echo -e "$echoPrefix cd $dirPath../runtime/ $echoSuffix" + cd $dirPath../runtime/ + echo -e "$echoPrefix java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./wms-system-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles --server.port=8084 >>/dev/null 2>&1 & $echoSuffix" + java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./wms-system-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles --server.port=8084 >>/dev/null 2>&1 & + echo "$serverName 启动成功!" + else + echo "$serverName 正在运行..." + fi + echo "查看日志: tail -F $logPath -n 100" +} + +stopServer() { + pid=$1 + if [ -z $pid ];then + echo "$serverName 未运行" + else + echo -e "$echoPrefix ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print \$2}' | xargs kill $echoSuffix" + ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}' | xargs kill + echo "$serverName 已停止!" + fi +} + +deployPull() { + for ((idx=0; idx<${#gitUrlArr[@]}; idx++)); do + pullCode $codePath ${gitUrlArr[idx]} ${branchArr[idx]} ${positionArr[idx]} + if [ "${needBuild[idx]}" == "-1" ]; then + needBuild[idx]=$isChange + fi + done + # 设置 require_config.js 前端版本 + # version=$(date +_%Y_%m_%d_%H_%M_%S) + # echo -e "$echoPrefix sed -i 's/_[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}/$version/g' $codePath/public/require_config.js $echoSuffix" + # sed -i "s/_[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}/$version/g" $codePath/public/require_config.js + echo "###--代码更新完成--------------------------------------------------------------------------###" + echo "" +} + +deployServer() { + pid=$1 + deployPull + buildCode + echo "###--代码构建完成--------------------------------------------------------------------------###" + # 重启服务 + if [ ! -z $pid ];then + stopServer $pid + sleep 8s + fi + # 移动编译后的文件 + moveBuildFile + startServer +} + +restartServer() { + pid=$1 + if [ ! -z $pid ];then + stopServer $pid + sleep 3s + fi + moveBuildFile + startServer +} + +logs() { + tail -F $logPath -n 100 +} + +deployYvanUI() { + bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/11yvan-vue.sh) deploy + bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/12yvan-vue-mobile.sh) deploy +} + +startPcUi() { + pid=`ps -ef | grep "${codePath}/wms-ui-pc/node_modules/.bin/vite" | grep -v 'grep' | awk '{print $2}'` + if [ -z $pid ];then + echo "wms-ui-pc 未运行" + else + echo -e "$echoPrefix ps -ef | grep "${codePath}/wms-ui-pc/node_modules/.bin/vite" | grep -v 'grep' | awk '{print \$2}' | xargs kill $echoSuffix" + ps -ef | grep "${codePath}/wms-ui-pc/node_modules/.bin/vite" | grep -v 'grep' | awk '{print $2}' | xargs kill + echo "wms-ui-pc 已停止!" + sleep 3s + fi + echo -e "$echoPrefix cd $codePath/wms-ui-pc $echoSuffix" + cd "$codePath/wms-ui-pc" + echo -e "$echoPrefix nohup yarn run dev >>/dev/null 2>&1 & $echoSuffix" + nohup yarn run dev >>/dev/null 2>&1 & +} + +startMobileUi() { + pid=`ps -ef | grep "${codePath}/wms-ui-mobile/node_modules/.bin/vite" | grep -v 'grep' | awk '{print $2}'` + if [ -z $pid ];then + echo "wms-ui-mobile 未运行" + else + echo -e "$echoPrefix ps -ef | grep "${codePath}/wms-ui-mobile/node_modules/.bin/vite" | grep -v 'grep' | awk '{print \$2}' | xargs kill $echoSuffix" + ps -ef | grep "${codePath}/wms-ui-mobile/node_modules/.bin/vite" | grep -v 'grep' | awk '{print $2}' | xargs kill + echo "wms-ui-mobile 已停止!" + sleep 3s + fi + echo -e "$echoPrefix cd $codePath/wms-ui-mobile $echoSuffix" + cd "$codePath/wms-ui-mobile" + echo -e "$echoPrefix nohup yarn run dev >>/dev/null 2>&1 & $echoSuffix" + nohup yarn run dev >>/dev/null 2>&1 & +} + +pid=`ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}'` +# 操作参数: pull build deploy restart start stop kill log logs startPc startMobile +if [ "$cmd" == "pull" ];then + deployYvanUI + deployPull + if [ -z $pid ];then + echo "$serverName 未运行 | 输入操作参数: pull build deploy restart start stop kill log logs startPc startMobile" + fi +elif [ "$cmd" == "build" ];then + deployYvanUI + deployPull + buildCode + echo "###--代码构建完成--------------------------------------------------------------------------###" +elif [ "$cmd" == "deploy" ];then + deployYvanUI + deployServer $pid + startPcUi + startMobileUi +elif [ "$cmd" == "restart" ];then + restartServer $pid +elif [ "$cmd" == "start" ];then + startServer $pid +elif [ "$cmd" == "stop" ] || [ "$cmd" == "kill" ];then + stopServer $pid +elif [ "$cmd" == "log" ] || [ "$cmd" == "logs" ];then + logs +elif [ "$cmd" == "startPc" ];then + startPcUi +elif [ "$cmd" == "startMobile" ];then + startMobileUi +else + if [ -z $pid ];then + echo "$serverName 未运行 | 输入操作参数: pull build deploy restart start stop kill log logs startPc startMobile" + echo "查看日志: tail -F $logPath -n 100" + else + echo "输入操作参数: pull build deploy restart start stop kill log logs startPc startMobile" + echo "pid=$pid | $serverName 正在运行... | 查看日志: tail -F $logPath -n 100" + fi +fi + +# 中通服-华为云-测试 +# bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/hua_wei_yun/04wms-ztf-test.sh) [cmd profiles] diff --git a/hua_wei_yun/06wms-ztf-filemanager-test.sh b/hua_wei_yun/06wms-ztf-filemanager-test.sh new file mode 100644 index 0000000..bd80d7b --- /dev/null +++ b/hua_wei_yun/06wms-ztf-filemanager-test.sh @@ -0,0 +1,202 @@ +#!/bin/bash +#set -x +set -e + +codePath=/home/www/deploy/wms8_ztf_api_2 +gitUrlArr=( + "http://git.yvanui.com/jztd/wms.git" + "http://git.yvanui.com/lizhiwei/yvan-framework.git" +) + +branchArr=( + "master" + "8.4" +) +positionArr=( + "." + "yvan-framework" +) +# 是否需要构建,-1:自动;0:不需要;1:需要 +needBuild=( +"1" +"1" +) + +echoPrefix="\033[36m+" +echoSuffix="\033[0m" + +# 强制覆盖本地的代码 git fetch --all && git reset --hard origin/master +isChange="1" # 仓库是否发生变化,0:未变化;非0:变化 +pullCode() { + # Usage: pullCode "codePath" "gitUrl" "branch" "position" + path=$1 # 代码保存路径 + gitUrl=$2 # git仓库地址 + branch=${3:-"master"} # git分支 + position=${4:-""} # 使用“.”clone到当前文件夹 + isChange="1" + # 创建文件夹 + if [ ! -d "$path" ]; then + echo -e "$echoPrefix 请检查服务器是否正确,再执行: mkdir -p $path $echoSuffix" + exit + fi + + # git clone + echo -e "$echoPrefix cd $path $echoSuffix" + cd $path + if [ "`ls -A $path`" == "" ] || [ ! -d "$path/$position" ] || [ "`ls -A $path/$position`" = "" ]; then + echo -e "$echoPrefix git clone $gitUrl $position $echoSuffix" + git clone $gitUrl $position + isChange="2" + fi + + # 进入文件夹,切换分支,git pull + if [ "$position" != "" ]; then + echo -e "$echoPrefix cd $position $echoSuffix" + cd $position + fi + echo -e "$echoPrefix git checkout $branch $echoSuffix" + git checkout $branch + echo -e "$echoPrefix git checkout . $echoSuffix" + git checkout . + echo -e "$echoPrefix git pull $echoSuffix" + if [ "`git pull`" == "Already up-to-date." ] && [ $isChange == "1" ]; then + isChange="0" + fi + echo "" +} + +buildCode() { + # 构建 java + echo -e "$echoPrefix cd $codePath $echoSuffix" + cd $codePath + echo -e "$echoPrefix gradle build -x test $echoSuffix" + gradle build -x test + echo "" +} + +logPath=/data/logs/wms8_ztf_filemanager_2/server.log +dirPath=/home/www/deploy/wms8_ztf_filemanager_2/wms-modules/wms-filemanager/build/libs/ +serverName=2_wms8_ztf_filemanager_2 + +cmd=$1 +profiles=${2:-"test"} + +#------------------------------------------------------------------- +JAVA_MEM_OPTS=" -DappName=${serverName} -server -Xmx2g -Xms2g" +DATABASE_OPTS=" -Ddatabase.codeset=ISO-8859-1 -Ddatabase.logging=false" +JAVA_OPTS_EXT=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dapplication.codeset=UTF-8 -Dfile.encoding=UTF-8 -Duser.timezone=Asia/Shanghai" +#------------------------------------------------------------------- + +moveBuildFile() { + # 移动编译后的文件 + echo -e "$echoPrefix cd $dirPath $echoSuffix" + cd $dirPath + echo -e "$echoPrefix rm -rf ../runtime $echoSuffix" + rm -rf ../runtime + echo -e "$echoPrefix cp -r ./ ../runtime $echoSuffix" + cp -r ./ ../runtime + echo "" +} + +startServer() { + pid=$1 + if [ -z $pid ];then + echo -e "$echoPrefix cd $dirPath../runtime/ $echoSuffix" + cd $dirPath../runtime/ + echo -e "$echoPrefix java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./wms-filemanager-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles --server.port=8084 >>/dev/null 2>&1 & $echoSuffix" + java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./wms-filemanager-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles --server.port=9084 >>/dev/null 2>&1 & + echo "$serverName 启动成功!" + else + echo "$serverName 正在运行..." + fi + echo "查看日志: tail -F $logPath -n 100" +} + +stopServer() { + pid=$1 + if [ -z $pid ];then + echo "$serverName 未运行" + else + echo -e "$echoPrefix ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print \$2}' | xargs kill $echoSuffix" + ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}' | xargs kill + echo "$serverName 已停止!" + fi +} + +deployPull() { + for ((idx=0; idx<${#gitUrlArr[@]}; idx++)); do + pullCode $codePath ${gitUrlArr[idx]} ${branchArr[idx]} ${positionArr[idx]} + if [ "${needBuild[idx]}" == "-1" ]; then + needBuild[idx]=$isChange + fi + done + # 设置 require_config.js 前端版本 + # version=$(date +_%Y_%m_%d_%H_%M_%S) + # echo -e "$echoPrefix sed -i 's/_[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}/$version/g' $codePath/public/require_config.js $echoSuffix" + # sed -i "s/_[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}/$version/g" $codePath/public/require_config.js + echo "###--代码更新完成--------------------------------------------------------------------------###" + echo "" +} + +deployServer() { + pid=$1 + deployPull + buildCode + echo "###--代码构建完成--------------------------------------------------------------------------###" + # 重启服务 + if [ ! -z $pid ];then + stopServer $pid + sleep 8s + fi + # 移动编译后的文件 + moveBuildFile + startServer +} + +restartServer() { + pid=$1 + if [ ! -z $pid ];then + stopServer $pid + sleep 3s + fi + moveBuildFile + startServer +} + +logs() { + tail -F $logPath -n 100 +} + +pid=`ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}'` +# 操作参数: pull build deploy restart start stop kill log logs +if [ "$cmd" == "pull" ];then + deployPull + if [ -z $pid ];then + echo "$serverName 未运行 | 输入操作参数: pull build deploy restart start stop kill log logs" + fi +elif [ "$cmd" == "build" ];then + deployPull + buildCode + echo "###--代码构建完成--------------------------------------------------------------------------###" +elif [ "$cmd" == "deploy" ];then + deployServer $pid +elif [ "$cmd" == "restart" ];then + restartServer $pid +elif [ "$cmd" == "start" ];then + startServer $pid +elif [ "$cmd" == "stop" ] || [ "$cmd" == "kill" ];then + stopServer $pid +elif [ "$cmd" == "log" ] || [ "$cmd" == "logs" ];then + logs +else + if [ -z $pid ];then + echo "$serverName 未运行 | 输入操作参数: pull build deploy restart start stop kill log logs" + echo "查看日志: tail -F $logPath -n 100" + else + echo "输入操作参数: pull build deploy restart start stop kill log logs" + echo "pid=$pid | $serverName 正在运行... | 查看日志: tail -F $logPath -n 100" + fi +fi + +# 中通服API-华为云-文件系统测试 +# bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/hua_wei_yun/06wms-ztf-filemanager-test.sh) [cmd profiles] diff --git a/hua_wei_yun/07wms-ztf-print-test.sh b/hua_wei_yun/07wms-ztf-print-test.sh new file mode 100644 index 0000000..8bc9b5d --- /dev/null +++ b/hua_wei_yun/07wms-ztf-print-test.sh @@ -0,0 +1,202 @@ +#!/bin/bash +#set -x +set -e + +codePath=/home/www/deploy/wms8_ztf_api_2 +gitUrlArr=( + "http://git.yvanui.com/jztd/wms.git" + "http://git.yvanui.com/lizhiwei/yvan-framework.git" +) + +branchArr=( + "master" + "8.4" +) +positionArr=( + "." + "yvan-framework" +) +# 是否需要构建,-1:自动;0:不需要;1:需要 +needBuild=( +"1" +"1" +) + +echoPrefix="\033[36m+" +echoSuffix="\033[0m" + +# 强制覆盖本地的代码 git fetch --all && git reset --hard origin/master +isChange="1" # 仓库是否发生变化,0:未变化;非0:变化 +pullCode() { + # Usage: pullCode "codePath" "gitUrl" "branch" "position" + path=$1 # 代码保存路径 + gitUrl=$2 # git仓库地址 + branch=${3:-"master"} # git分支 + position=${4:-""} # 使用“.”clone到当前文件夹 + isChange="1" + # 创建文件夹 + if [ ! -d "$path" ]; then + echo -e "$echoPrefix 请检查服务器是否正确,再执行: mkdir -p $path $echoSuffix" + exit + fi + + # git clone + echo -e "$echoPrefix cd $path $echoSuffix" + cd $path + if [ "`ls -A $path`" == "" ] || [ ! -d "$path/$position" ] || [ "`ls -A $path/$position`" = "" ]; then + echo -e "$echoPrefix git clone $gitUrl $position $echoSuffix" + git clone $gitUrl $position + isChange="2" + fi + + # 进入文件夹,切换分支,git pull + if [ "$position" != "" ]; then + echo -e "$echoPrefix cd $position $echoSuffix" + cd $position + fi + echo -e "$echoPrefix git checkout $branch $echoSuffix" + git checkout $branch + echo -e "$echoPrefix git checkout . $echoSuffix" + git checkout . + echo -e "$echoPrefix git pull $echoSuffix" + if [ "`git pull`" == "Already up-to-date." ] && [ $isChange == "1" ]; then + isChange="0" + fi + echo "" +} + +buildCode() { + # 构建 java + echo -e "$echoPrefix cd $codePath $echoSuffix" + cd $codePath + echo -e "$echoPrefix gradle build -x test $echoSuffix" + gradle build -x test + echo "" +} + +logPath=/data/logs/wms8_ztf_print_2/server.log +dirPath=/home/www/deploy/wms8_ztf_print_2/wms-modules/wms-print/build/libs/ +serverName=2_wms8_ztf_print_2 + +cmd=$1 +profiles=${2:-"test"} + +#------------------------------------------------------------------- +JAVA_MEM_OPTS=" -DappName=${serverName} -server -Xmx2g -Xms2g" +DATABASE_OPTS=" -Ddatabase.codeset=ISO-8859-1 -Ddatabase.logging=false" +JAVA_OPTS_EXT=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dapplication.codeset=UTF-8 -Dfile.encoding=UTF-8 -Duser.timezone=Asia/Shanghai" +#------------------------------------------------------------------- + +moveBuildFile() { + # 移动编译后的文件 + echo -e "$echoPrefix cd $dirPath $echoSuffix" + cd $dirPath + echo -e "$echoPrefix rm -rf ../runtime $echoSuffix" + rm -rf ../runtime + echo -e "$echoPrefix cp -r ./ ../runtime $echoSuffix" + cp -r ./ ../runtime + echo "" +} + +startServer() { + pid=$1 + if [ -z $pid ];then + echo -e "$echoPrefix cd $dirPath../runtime/ $echoSuffix" + cd $dirPath../runtime/ + echo -e "$echoPrefix java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./wms-print-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles --server.port=8084 >>/dev/null 2>&1 & $echoSuffix" + java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./wms-print-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles --server.port=9084 >>/dev/null 2>&1 & + echo "$serverName 启动成功!" + else + echo "$serverName 正在运行..." + fi + echo "查看日志: tail -F $logPath -n 100" +} + +stopServer() { + pid=$1 + if [ -z $pid ];then + echo "$serverName 未运行" + else + echo -e "$echoPrefix ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print \$2}' | xargs kill $echoSuffix" + ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}' | xargs kill + echo "$serverName 已停止!" + fi +} + +deployPull() { + for ((idx=0; idx<${#gitUrlArr[@]}; idx++)); do + pullCode $codePath ${gitUrlArr[idx]} ${branchArr[idx]} ${positionArr[idx]} + if [ "${needBuild[idx]}" == "-1" ]; then + needBuild[idx]=$isChange + fi + done + # 设置 require_config.js 前端版本 + # version=$(date +_%Y_%m_%d_%H_%M_%S) + # echo -e "$echoPrefix sed -i 's/_[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}/$version/g' $codePath/public/require_config.js $echoSuffix" + # sed -i "s/_[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}/$version/g" $codePath/public/require_config.js + echo "###--代码更新完成--------------------------------------------------------------------------###" + echo "" +} + +deployServer() { + pid=$1 + deployPull + buildCode + echo "###--代码构建完成--------------------------------------------------------------------------###" + # 重启服务 + if [ ! -z $pid ];then + stopServer $pid + sleep 8s + fi + # 移动编译后的文件 + moveBuildFile + startServer +} + +restartServer() { + pid=$1 + if [ ! -z $pid ];then + stopServer $pid + sleep 3s + fi + moveBuildFile + startServer +} + +logs() { + tail -F $logPath -n 100 +} + +pid=`ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}'` +# 操作参数: pull build deploy restart start stop kill log logs +if [ "$cmd" == "pull" ];then + deployPull + if [ -z $pid ];then + echo "$serverName 未运行 | 输入操作参数: pull build deploy restart start stop kill log logs" + fi +elif [ "$cmd" == "build" ];then + deployPull + buildCode + echo "###--代码构建完成--------------------------------------------------------------------------###" +elif [ "$cmd" == "deploy" ];then + deployServer $pid +elif [ "$cmd" == "restart" ];then + restartServer $pid +elif [ "$cmd" == "start" ];then + startServer $pid +elif [ "$cmd" == "stop" ] || [ "$cmd" == "kill" ];then + stopServer $pid +elif [ "$cmd" == "log" ] || [ "$cmd" == "logs" ];then + logs +else + if [ -z $pid ];then + echo "$serverName 未运行 | 输入操作参数: pull build deploy restart start stop kill log logs" + echo "查看日志: tail -F $logPath -n 100" + else + echo "输入操作参数: pull build deploy restart start stop kill log logs" + echo "pid=$pid | $serverName 正在运行... | 查看日志: tail -F $logPath -n 100" + fi +fi + +# 中通服API-华为云-打印服务测试 +# bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/hua_wei_yun/07wms-ztf-print-test.sh) [cmd profiles]