From 137121e594b5c4867af3aedb2b369acd90b3bfa1 Mon Sep 17 00:00:00 2001 From: lizw Date: Wed, 29 Dec 2021 19:13:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E5=8F=82=E6=9E=97=20=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E9=83=A8=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dsl/build.sh | 238 +++++++++++++++++++++-------------------------------------- 1 file changed, 84 insertions(+), 154 deletions(-) diff --git a/dsl/build.sh b/dsl/build.sh index 659611e..e650aa3 100644 --- a/dsl/build.sh +++ b/dsl/build.sh @@ -28,157 +28,6 @@ needBuild=( echoPrefix="\033[36m+" echoSuffix="\033[0m" -buildCode() { - # 构建 yvan-ext - if [ "${needBuild[1]}" != "0" ]; then - echo -e "$echoPrefix cd $codePath/yvan-ext $echoSuffix" - cd "$codePath/yvan-ext" - echo -e "$echoPrefix yarn $echoSuffix" - yarn - echo -e "$echoPrefix yarn link $echoSuffix" - yarn link - echo -e "$echoPrefix yarn build $echoSuffix" - yarn build - echo "" - else - echo "yvan-ext 文件未变化" - fi - - # 构建 thinkingwms-ui/client - if [ "${needBuild[2]}" != "0" ]; then - echo -e "$echoPrefix cd $codePath/thinkingwms-ui/client $echoSuffix" - cd "$codePath/thinkingwms-ui/client" - echo -e "$echoPrefix yarn $echoSuffix" - yarn - echo -e "$echoPrefix yarn link yvan-ext $echoSuffix" - yarn link yvan-ext - echo -e "$echoPrefix yarn build $echoSuffix" - yarn build - echo "" - else - echo "thinkingwms-ui 文件未变化" - fi - - # 构建 java - echo -e "$echoPrefix cd $codePath $echoSuffix" - cd $codePath - echo -e "$echoPrefix gradle build -x test $echoSuffix" - gradle build -x test - echo "" -} - -deployPush() { - # 更新push git - pullCode $pushPath $pushGitUrl "master" "." - - # 同步 lmis/ent/build/libs - echo -e "$echoPrefix rsync -av --delete --exclude '.git/' --exclude 'client/' --exclude 'dist/' --exclude '*-javadoc.jar' --exclude '*-sources.jar' $codePath/lmis/ent/build/libs/ $pushPath/ $echoSuffix" - rsync -av --delete --exclude '.git/' --exclude 'client/' --exclude 'dist/' --exclude '*-javadoc.jar' --exclude '*-sources.jar' "$codePath/lmis/ent/build/libs/" "$pushPath/" - echo "" - - # 同步 lmis/client/tsconfig.json - echo -e "$echoPrefix rsync -av --delete --include 'tsconfig.json' --exclude '/*' $codePath/lmis/client/ $pushPath/client/ $echoSuffix" - rsync -av --delete --include 'tsconfig.json' --exclude '/*' "$codePath/lmis/client/" "$pushPath/client/" - echo "" - - # 同步 lmis/client/node_modules - echo -e "$echoPrefix rsync -av --delete --exclude 'yvan-ext/' $codePath/lmis/client/node_modules/ $pushPath/client/node_modules/ $echoSuffix" - rsync -av --delete --exclude 'yvan-ext' "$codePath/lmis/client/node_modules/" "$pushPath/client/node_modules/" - echo "" - - # 同步 lmis/client/public - echo -e "$echoPrefix rsync -av --delete $codePath/lmis/client/public/ $pushPath/client/public/ $echoSuffix" - rsync -av --delete "$codePath/lmis/client/public/" "$pushPath/client/public/" - echo "" - - # 同步 yvan-ext - echo -e "$echoPrefix rsync -av --delete --include 'assets/' --include 'build/' --include 'dist/' --exclude '/*' $codePath/yvan-ext/ $pushPath/client/node_modules/yvan-ext/ $echoSuffix" - rsync -av --delete --include 'assets/' --include 'build/' --include 'dist/' --exclude '/*' "$codePath/yvan-ext/" "$pushPath/client/node_modules/yvan-ext/" - echo "" - - # 同步 lmis/dist - echo -e "$echoPrefix rsync -av --delete $codePath/lmis/dist/ $pushPath/dist/ $echoSuffix" - rsync -av --delete "$codePath/lmis/dist/" "$pushPath/dist/" - echo "" - - # 提交文件 - echo -e "$echoPrefix cd $pushPath $echoSuffix" - cd "$pushPath" - if [ -n "$(git config user.name)" ]; then - echo -e "$echoPrefix git config user.name 'bot' $echoSuffix" - git config user.name 'bot' - echo -e "$echoPrefix git config user.email 'bot@git.com' $echoSuffix" - git config user.email 'bot@git.com' - fi - echo -e "$echoPrefix git add -A $echoSuffix" - git add -A - if [ -n "$(git status -s)" ]; then - echo -e "$echoPrefix git commit -am 自动deploy提交 $echoSuffix" - git commit -am "自动deploy提交" - echo -e "$echoPrefix git push origin master $echoSuffix" - git push origin master - else - echo "文件未变化不需要push" - fi - echo "" - - #--------------------------------------------------------------------------------------------------------------------- - - # 更新push git - pullCode $pushPath_2 $pushGitUrl_2 "master" "." - - # 同步 lmis-report-system/app/build/libs - echo -e "$echoPrefix rsync -av --delete --exclude '.git/' --exclude 'client/' --exclude 'dist/' --exclude '*-javadoc.jar' --exclude '*-sources.jar' $codePath/lmis-report-system/app/build/libs/ $pushPath_2/ $echoSuffix" - rsync -av --delete --exclude '.git/' --exclude 'client/' --exclude 'dist/' --exclude '*-javadoc.jar' --exclude '*-sources.jar' "$codePath/lmis-report-system/app/build/libs/" "$pushPath_2/" - echo "" - - # 同步 lmis-report-system/client/tsconfig.json - echo -e "$echoPrefix rsync -av --delete --include 'tsconfig.json' --exclude '/*' $codePath/lmis-report-system/client/ $pushPath_2/client/ $echoSuffix" - rsync -av --delete --include 'tsconfig.json' --exclude '/*' "$codePath/lmis-report-system/client/" "$pushPath_2/client/" - echo "" - - # 同步 lmis-report-system/client/node_modules - echo -e "$echoPrefix rsync -av --delete --exclude 'yvan-ext/' $codePath/lmis-report-system/client/node_modules/ $pushPath_2/client/node_modules/ $echoSuffix" - rsync -av --delete --exclude 'yvan-ext' "$codePath/lmis-report-system/client/node_modules/" "$pushPath_2/client/node_modules/" - echo "" - - # 同步 lmis-report-system/client/public - echo -e "$echoPrefix rsync -av --delete $codePath/lmis-report-system/client/public/ $pushPath_2/client/public/ $echoSuffix" - rsync -av --delete "$codePath/lmis-report-system/client/public/" "$pushPath_2/client/public/" - echo "" - - # 同步 yvan-ext - echo -e "$echoPrefix rsync -av --delete --include 'assets/' --include 'build/' --include 'dist/' --exclude '/*' $codePath/yvan-ext/ $pushPath_2/client/node_modules/yvan-ext/ $echoSuffix" - rsync -av --delete --include 'assets/' --include 'build/' --include 'dist/' --exclude '/*' "$codePath/yvan-ext/" "$pushPath_2/client/node_modules/yvan-ext/" - echo "" - - # 同步 lmis-report-system/dist - echo -e "$echoPrefix rsync -av --delete $codePath/lmis-report-system/dist/ $pushPath_2/dist/ $echoSuffix" - rsync -av --delete "$codePath/lmis-report-system/dist/" "$pushPath_2/dist/" - echo "" - - # 提交文件 - echo -e "$echoPrefix cd $pushPath_2 $echoSuffix" - cd "$pushPath_2" - if [ -n "$(git config user.name)" ]; then - echo -e "$echoPrefix git config user.name 'bot' $echoSuffix" - git config user.name 'bot' - echo -e "$echoPrefix git config user.email 'bot@git.com' $echoSuffix" - git config user.email 'bot@git.com' - fi - echo -e "$echoPrefix git add -A $echoSuffix" - git add -A - if [ -n "$(git status -s)" ]; then - echo -e "$echoPrefix git commit -am 自动deploy提交 $echoSuffix" - git commit -am "自动deploy提交" - echo -e "$echoPrefix git push origin master $echoSuffix" - git push origin master - else - echo "文件未变化不需要push" - fi - echo "" -} - isChange="1" # 仓库是否发生变化,0:未变化;非0:变化 pullCode() { # Usage: pullCode "codePath" "gitUrl" "branch" "position" @@ -225,12 +74,93 @@ done echo "###--代码更新完成--------------------------------------------------------------------------###" echo "" +buildCode() { + # 构建 yvan-ext + if [ "${needBuild[1]}" != "0" ]; then + echo -e "$echoPrefix cd $codePath/yvan-ext $echoSuffix" + cd "$codePath/yvan-ext" + echo -e "$echoPrefix yarn $echoSuffix" + yarn + echo -e "$echoPrefix yarn link $echoSuffix" + yarn link + echo -e "$echoPrefix yarn build $echoSuffix" + yarn build + echo "" + else + echo "yvan-ext 文件未变化" + fi + + # 构建 thinkingwms-ui/client + if [ "${needBuild[2]}" != "0" ]; then + echo -e "$echoPrefix cd $codePath/thinkingwms-ui/client $echoSuffix" + cd "$codePath/thinkingwms-ui/client" + echo -e "$echoPrefix yarn $echoSuffix" + yarn + echo -e "$echoPrefix yarn link yvan-ext $echoSuffix" + yarn link yvan-ext + echo -e "$echoPrefix yarn build $echoSuffix" + yarn build + echo "" + else + echo "thinkingwms-ui 文件未变化" + fi + + # 构建 java + echo -e "$echoPrefix cd $codePath $echoSuffix" + cd $codePath + echo -e "$echoPrefix gradle build -x test $echoSuffix" + gradle build -x test + echo "" +} + buildCode echo "###--代码构建完成--------------------------------------------------------------------------###" echo "" -#deployPush -#echo "###--文件推送完成--------------------------------------------------------------------------###" -#echo "" +logPath=/data3/thinkingwms_nohup.log +dirPath=/data3/yvan-framework/thinkingwms-ui/thinkingwms-backend/build/libs/ +serverName=dsl_thinkingwms_ui + +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" +#------------------------------------------------------------------- + +startServer() { + pid=$1 + if [ -z $pid ];then + echo -e "$echoPrefix cd $dirPath $echoSuffix" + cd $dirPath + echo -e "$echoPrefix java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./thinkingwms-backend-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles >$logPath 2>&1 & $echoSuffix" + java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./thinkingwms-backend-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles >$logPath 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 +} + +pid=`ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}'` +if [ ! -z $pid ];then + stopServer $pid + sleep 3s +fi +startServer # bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/dsl/build.sh) +