Selaa lähdekoodia

大参林 服务部署

lizw 3 vuotta sitten
vanhempi
commit
137121e594
1 muutettua tiedostoa jossa 84 lisäystä ja 154 poistoa
  1. 84 154
      dsl/build.sh

+ 84 - 154
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)
+