test-deploy-wms8-pgsql.sh 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. ##!/bin/bash
  2. ##set -x
  3. #set -e
  4. #
  5. #codePath=/home/www/deploy/wms8_test_pgsql
  6. #gitUrlArr=(
  7. # "http://git.galaxis.yvanui.com/wms8/wms8-bench.git"
  8. # "http://git.yvanui.com/lizhiwei/yvan-framework.git"
  9. # "http://git.galaxis.yvanui.com/wms8/wms-core.git"
  10. #)
  11. #
  12. #branchArr=(
  13. # "pgsql"
  14. # "master"
  15. # "pgsql"
  16. #)
  17. #positionArr=(
  18. # "."
  19. # "yvan-framework"
  20. # "wms-core"
  21. #)
  22. ## 是否需要构建,-1:自动;0:不需要;1:需要
  23. #needBuild=(
  24. #"1"
  25. #"1"
  26. #"1"
  27. #)
  28. #
  29. #echoPrefix="\033[36m+"
  30. #echoSuffix="\033[0m"
  31. #
  32. ## 强制覆盖本地的代码 git fetch --all && git reset --hard origin/master
  33. #isChange="1" # 仓库是否发生变化,0:未变化;非0:变化
  34. #pullCode() {
  35. # # Usage: pullCode "codePath" "gitUrl" "branch" "position"
  36. # path=$1 # 代码保存路径
  37. # gitUrl=$2 # git仓库地址
  38. # branch=${3:-"master"} # git分支
  39. # position=${4:-""} # 使用“.”clone到当前文件夹
  40. # isChange="1"
  41. # # 创建文件夹
  42. # if [ ! -d "$path" ]; then
  43. # echo -e "$echoPrefix 请检查服务器是否正确,再执行: mkdir -p $path $echoSuffix"
  44. # exit
  45. # fi
  46. #
  47. # # git clone
  48. # echo -e "$echoPrefix cd $path $echoSuffix"
  49. # cd $path
  50. # if [ "`ls -A $path`" == "" ] || [ ! -d "$path/$position" ] || [ "`ls -A $path/$position`" = "" ]; then
  51. # echo -e "$echoPrefix git clone $gitUrl $position $echoSuffix"
  52. # git clone $gitUrl $position
  53. # isChange="2"
  54. # fi
  55. #
  56. # # 进入文件夹,切换分支,git pull
  57. # if [ "$position" != "" ]; then
  58. # echo -e "$echoPrefix cd $position $echoSuffix"
  59. # cd $position
  60. # fi
  61. # echo -e "$echoPrefix git checkout $branch $echoSuffix"
  62. # git checkout $branch
  63. # echo -e "$echoPrefix git checkout . $echoSuffix"
  64. # git checkout .
  65. # echo -e "$echoPrefix git pull $echoSuffix"
  66. # if [ "`git pull`" == "Already up-to-date." ] && [ $isChange == "1" ]; then
  67. # isChange="0"
  68. # fi
  69. # echo ""
  70. #}
  71. #
  72. #buildCode() {
  73. # # 构建 wms-biz/bundle
  74. # if [ "${needBuild[0]}" != "0" ]; then
  75. # echo -e "$echoPrefix cd $codePath/wms-biz/bundle $echoSuffix"
  76. # cd "$codePath/wms-biz/bundle"
  77. # echo -e "$echoPrefix yarn $echoSuffix"
  78. # yarn
  79. # echo -e "$echoPrefix yarn link yvan-ext $echoSuffix"
  80. # yarn link yvan-ext
  81. # echo -e "$echoPrefix yarn build $echoSuffix"
  82. # yarn build
  83. # echo ""
  84. # else
  85. # echo "wms-biz/bundle 文件未变化"
  86. # fi
  87. #
  88. # # 构建 wms-biz/pda-client
  89. # if [ "${needBuild[0]}" != "0" ]; then
  90. # echo -e "$echoPrefix cd $codePath/wms-biz/pda-client $echoSuffix"
  91. # cd "$codePath/wms-biz/pda-client"
  92. # echo -e "$echoPrefix yarn $echoSuffix"
  93. # yarn
  94. # echo -e "$echoPrefix yarn link yvan-ext-mobile $echoSuffix"
  95. # yarn link yvan-ext-mobile
  96. # echo -e "$echoPrefix yarn build $echoSuffix"
  97. # yarn build
  98. # echo ""
  99. # else
  100. # echo "wms-biz/pda-client 文件未变化"
  101. # fi
  102. #
  103. # # 构建 java
  104. # echo -e "$echoPrefix cd $codePath $echoSuffix"
  105. # cd $codePath
  106. # echo -e "$echoPrefix gradle build -x test $echoSuffix"
  107. # gradle build -x test
  108. # echo ""
  109. #}
  110. #
  111. #logPath=/data/logs/wms8_test_pgsql/wms8_test_pgsql.log
  112. #dirPath=/home/www/deploy/wms8_test_pgsql/wms-biz/servo/build/libs/
  113. #serverName=wms8_test_pgsql
  114. #
  115. #cmd=$1
  116. #profiles=${2:-"pg-yn-test"}
  117. #
  118. ##-------------------------------------------------------------------
  119. #JAVA_MEM_OPTS=" -DappName=${serverName} -server -Xmx2g -Xms2g"
  120. #DATABASE_OPTS=" -Ddatabase.codeset=ISO-8859-1 -Ddatabase.logging=false"
  121. #JAVA_OPTS_EXT=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dapplication.codeset=UTF-8 -Dfile.encoding=UTF-8 -Duser.timezone=Asia/Shanghai -Duser.name=user"
  122. ##-------------------------------------------------------------------
  123. #
  124. #startServer() {
  125. # pid=$1
  126. # if [ -z $pid ];then
  127. # echo -e "$echoPrefix cd $dirPath../runtime/ $echoSuffix"
  128. # cd $dirPath../runtime/
  129. # echo -e "$echoPrefix java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./servo-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles --server.port=18095 >>/dev/null 2>&1 & $echoSuffix"
  130. # java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./servo-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles --server.port=18095 >>/dev/null 2>&1 &
  131. # echo "$serverName 启动成功!"
  132. # else
  133. # echo "$serverName 正在运行..."
  134. # fi
  135. # echo "查看日志: tail -F $logPath -n 100"
  136. #}
  137. #
  138. #stopServer() {
  139. # pid=$1
  140. # if [ -z $pid ];then
  141. # echo "$serverName 未运行"
  142. # else
  143. # echo -e "$echoPrefix ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print \$2}' | xargs kill $echoSuffix"
  144. # ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}' | xargs kill
  145. # echo "$serverName 已停止!"
  146. # fi
  147. #}
  148. #
  149. #deployPull() {
  150. # for ((idx=0; idx<${#gitUrlArr[@]}; idx++)); do
  151. # pullCode $codePath ${gitUrlArr[idx]} ${branchArr[idx]} ${positionArr[idx]}
  152. # if [ "${needBuild[idx]}" == "-1" ]; then
  153. # needBuild[idx]=$isChange
  154. # fi
  155. # done
  156. # # 设置 require_config.js 前端版本
  157. # version=$(date +_%Y_%m_%d_%H_%M_%S)
  158. # 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"
  159. # 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
  160. # echo "###--代码更新完成--------------------------------------------------------------------------###"
  161. # echo ""
  162. #}
  163. #
  164. #deployServer() {
  165. # pid=$1
  166. # deployPull
  167. # buildCode
  168. # echo "###--代码构建完成--------------------------------------------------------------------------###"
  169. # # 重启服务
  170. # if [ ! -z $pid ];then
  171. # stopServer $pid
  172. # sleep 3s
  173. # fi
  174. # # 移动编译后的文件
  175. # echo -e "$echoPrefix cd $dirPath $echoSuffix"
  176. # cd $dirPath
  177. # echo -e "$echoPrefix rm -rf ../runtime $echoSuffix"
  178. # rm -rf ../runtime
  179. # echo -e "$echoPrefix cp -r ./ ../runtime $echoSuffix"
  180. # cp -r ./ ../runtime
  181. # echo ""
  182. # startServer
  183. #}
  184. #
  185. #restartServer() {
  186. # pid=$1
  187. # if [ ! -z $pid ];then
  188. # stopServer $pid
  189. # sleep 3s
  190. # fi
  191. # startServer
  192. #}
  193. #
  194. #logs() {
  195. # tail -F $logPath -n 100
  196. #}
  197. #
  198. #deployYvanUI() {
  199. # bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/01yvan-ext.sh) pull
  200. # bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/02yvan-ext-mobile.sh) pull
  201. #}
  202. #
  203. #pid=`ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}'`
  204. ## 操作参数: pull deploy restart start stop kill log logs
  205. #if [ "$cmd" == "pull" ];then
  206. # deployYvanUI
  207. # deployPull
  208. # if [ -z $pid ];then
  209. # echo "$serverName 未运行 | 输入操作参数: pull deploy restart start stop kill log logs"
  210. # fi
  211. #elif [ "$cmd" == "deploy" ];then
  212. # deployYvanUI
  213. # deployServer $pid
  214. #elif [ "$cmd" == "restart" ];then
  215. # restartServer $pid
  216. #elif [ "$cmd" == "start" ];then
  217. # startServer $pid
  218. #elif [ "$cmd" == "stop" ] || [ "$cmd" == "kill" ];then
  219. # stopServer $pid
  220. #elif [ "$cmd" == "log" ] || [ "$cmd" == "logs" ];then
  221. # logs
  222. #else
  223. # if [ -z $pid ];then
  224. # echo "$serverName 未运行 | 输入操作参数: pull deploy restart start stop kill log logs"
  225. # else
  226. # echo "输入操作参数: pull deploy restart start stop kill log logs"
  227. # echo "pid=$pid | $serverName 正在运行... | 查看日志: tail -F $logPath -n 100"
  228. # fi
  229. #fi
  230. #
  231. ## 一心堂pgsql wms
  232. ## bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/yxt-pg-test/test-deploy-wms8-pgsql.sh) [cmd profiles]