From c325064c9efa79db4e59736bef47c173fd85181d Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 12:42:12 +0800 Subject: [PATCH 01/24] 01yvan-ext.groovy 02yvan-ext-mobile.groovy --- .gitignore | 1 + 00base/01yvan-ext.groovy | 30 ++++++++++++++++++++++++++++++ 00base/02yvan-ext-mobile.groovy | 30 ++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 00base/01yvan-ext.groovy create mode 100644 00base/02yvan-ext-mobile.groovy diff --git a/.gitignore b/.gitignore index b757856..5115d3b 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,4 @@ target pom.xml.versionsBackup build/ node_modules +lib \ No newline at end of file diff --git a/00base/01yvan-ext.groovy b/00base/01yvan-ext.groovy new file mode 100644 index 0000000..4f1407c --- /dev/null +++ b/00base/01yvan-ext.groovy @@ -0,0 +1,30 @@ +//file:noinspection ALL +pipeline { + agent any + + environment { + projectName = 'yvan-ext' + } + + stages { + stage('#检查环境') { + steps { + sh """ + node -v + npm -v + yarn -v + """ + } + } + + stage('#编译项目') { + steps { + sh """ + wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/01yvan-ext.sh + chmod +x 01yvan-ext.sh + ./01yvan-ext.sh deploy + """ + } + } + } +} diff --git a/00base/02yvan-ext-mobile.groovy b/00base/02yvan-ext-mobile.groovy new file mode 100644 index 0000000..ed65487 --- /dev/null +++ b/00base/02yvan-ext-mobile.groovy @@ -0,0 +1,30 @@ +//file:noinspection ALL +pipeline { + agent any + + environment { + projectName = 'yvan-ext-mobile' + } + + stages { + stage('#检查环境') { + steps { + sh """ + node -v + npm -v + yarn -v + """ + } + } + + stage('#编译项目') { + steps { + sh """ + wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/02yvan-ext-mobile.sh + chmod +x 02yvan-ext-mobile.sh + ./02yvan-ext-mobile.sh deploy + """ + } + } + } +} From e77be533a6784c37f282433a278010dc7e1a73c8 Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 13:34:45 +0800 Subject: [PATCH 02/24] 03xxljob.groovy --- 00base/03xxljob.groovy | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 00base/03xxljob.groovy diff --git a/00base/03xxljob.groovy b/00base/03xxljob.groovy new file mode 100644 index 0000000..bface51 --- /dev/null +++ b/00base/03xxljob.groovy @@ -0,0 +1,28 @@ +//file:noinspection ALL +pipeline { + agent any + + environment { + projectName = 'xxl-job' + } + + stages { + stage('#检查环境') { + steps { + sh """ + java -version + """ + } + } + + stage('#编译项目') { + steps { + sh """ + wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/03xxljob.sh + chmod +x 03xxljob + ./03xxljob deploy + """ + } + } + } +} From 72815633a1d228d29211e0fe17bcc38ed9bc77f3 Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 14:32:54 +0800 Subject: [PATCH 03/24] 03xxljob.groovy --- 00base/03xxljob.groovy | 8 +++-- 05shengke/03xxljob-prod.sh | 81 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 05shengke/03xxljob-prod.sh diff --git a/00base/03xxljob.groovy b/00base/03xxljob.groovy index bface51..8121e07 100644 --- a/00base/03xxljob.groovy +++ b/00base/03xxljob.groovy @@ -19,8 +19,12 @@ pipeline { steps { sh """ wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/03xxljob.sh - chmod +x 03xxljob - ./03xxljob deploy + chmod +x 03xxljob.sh + wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/05shengke/03xxljob-prod.sh + chmod +x 03xxljob-prod.sh + ./03xxljob-prod.sh stop + ./03xxljob.sh pull + ./03xxljob-prod.sh start """ } } diff --git a/05shengke/03xxljob-prod.sh b/05shengke/03xxljob-prod.sh new file mode 100644 index 0000000..1f1dce4 --- /dev/null +++ b/05shengke/03xxljob-prod.sh @@ -0,0 +1,81 @@ +#!/bin/bash +#set -x +set -e + +echoPrefix="\033[36m+" +echoSuffix="\033[0m" + +logPath=/data/logs/xxl-job/xxl-job.log +dirPath=/home/www/deploy/xxl-job/ +serverName=xxl_job_prod + +cmd=$1 +profiles=${2:-"shengke-prod"} + +#------------------------------------------------------------------- +JAVA_MEM_OPTS=" -DappName=${serverName} -server -Xmx1g -Xms1g" +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 bin/xxl-job-admin-postgres-2.3.0.jar --spring.config.location=conf/ --spring.profiles.active=global,$profiles --server.port=8000 >>/dev/null 2>&1 & $echoSuffix" + java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar bin/xxl-job-admin-postgres-2.3.0.jar --spring.config.location=conf/ --spring.profiles.active=global,$profiles --server.port=8000 >>/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 +} + +restartServer() { + pid=$1 + if [ ! -z $pid ];then + stopServer $pid + sleep 3s + fi + startServer +} + +logs() { + tail -F $logPath -n 100 +} + +pid=`ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}'` +# 操作参数: deploy restart start stop kill log logs +if [ "$cmd" == "deploy" ];then + bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/03xxljob.sh) pull + restartServer $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 未运行 | 输入操作参数: deploy restart start stop kill log logs" + else + echo "输入操作参数: deploy restart start stop kill log logs" + echo "pid=$pid | $serverName 正在运行... | 查看日志: tail -F $logPath -n 100" + fi +fi + +# bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/05shengke/03xxljob-prod.sh) [cmd profiles] From 27f6e9b3eda6ba068175bba29b3217e2433e154f Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 15:53:45 +0800 Subject: [PATCH 04/24] 07env-install-centos.sh --- 00base/03xxljob.groovy | 32 --------- 00base/07env-install-centos.sh | 148 ++++++++++++++++++++++++++++++++++++++++- 05shengke/03xxljob.groovy | 32 +++++++++ 3 files changed, 179 insertions(+), 33 deletions(-) delete mode 100644 00base/03xxljob.groovy create mode 100644 05shengke/03xxljob.groovy diff --git a/00base/03xxljob.groovy b/00base/03xxljob.groovy deleted file mode 100644 index 8121e07..0000000 --- a/00base/03xxljob.groovy +++ /dev/null @@ -1,32 +0,0 @@ -//file:noinspection ALL -pipeline { - agent any - - environment { - projectName = 'xxl-job' - } - - stages { - stage('#检查环境') { - steps { - sh """ - java -version - """ - } - } - - stage('#编译项目') { - steps { - sh """ - wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/03xxljob.sh - chmod +x 03xxljob.sh - wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/05shengke/03xxljob-prod.sh - chmod +x 03xxljob-prod.sh - ./03xxljob-prod.sh stop - ./03xxljob.sh pull - ./03xxljob-prod.sh start - """ - } - } - } -} diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index a91e0bd..030d866 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -41,6 +41,10 @@ JENKINS_FILE_NAME="jenkins.war" JENKINS_JAVA_URL="https://d6.injdk.cn/oraclejdk/11/jdk-11.0.16.1_linux-x64_bin.tar.gz" JENKINS_JAVA_FILE_NAME="jdk-11.0.16.1_linux-x64_bin.tar.gz" JENKINS_JAVA_DIR_NAME="jdk-11.0.16.1" +#--- redis Latest Stable +REDIS_URL="https://download.redis.io/redis-stable.tar.gz" +REDIS_FILE_NAME="redis-stable.tar.gz" +REDIS_DIR_NAME="redis-stable" # 安装标识 #--- SSH用户 @@ -68,6 +72,7 @@ JAVA_TAG="1" GRADLE_TAG="1" MAVEN_TAG="1" JENKINS_TAG="1" +REDIS_TAG="1" # 脚本设置 TMP_DIR="$(rm -rf /tmp/env-install* && mktemp -d -t env-install.XXXXXXXXXX)" @@ -550,6 +555,141 @@ EOF log::info "[jenkins]" "停止jenkins: ${BASE_DIR}/jenkins/kill.sh" } +# 安装redis环境 +function init:redis() { + log::info "[redis]" "安装redis环境..." + local host="127.0.0.1" + local redis_path="${BASE_DIR}/redis/${REDIS_DIR_NAME}" + local redis_install_path="${BASE_DIR}/redis/${REDIS_DIR_NAME}-install" + command::exec "${host}" " + if [ ! -d "$redis_path" ]; then + mkdir -p ${BASE_DIR}/redis + wget --timeout=10 --waitretry=3 --tries=5 --retry-connrefused --no-check-certificate ${REDIS_URL} -O ${BASE_DIR}/redis/${REDIS_FILE_NAME} + cd ${BASE_DIR}/redis + tar -zxvf ${REDIS_FILE_NAME} + cd $redis_path + yum -y install gcc + yum -y install centos-release-scl + yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils + scl enable devtoolset-9 bash + echo 'source /opt/rh/devtoolset-9/enable' >> /etc/profile + gcc -v + cd $redis_path + make install PREFIX=$redis_install_path + # 写文件start.sh文件 + cat << EOF > $redis_install_path/redis.conf +# bind 127.0.0.1 +protected-mode yes +port 6379 +tcp-backlog 511 +timeout 300 +tcp-keepalive 300 +daemonize yes +supervised auto +pidfile $redis_install_path/redis.pid +loglevel notice +logfile $redis_install_path/redis.log +databases 16 +always-show-logo yes +save 900 1 +save 300 10 +save 60 10000 +stop-writes-on-bgsave-error yes +rdbcompression yes +rdbchecksum yes +dbfilename dump.rdb +rdb-del-sync-files no +dir $redis_install_path/ +replica-serve-stale-data yes +replica-read-only yes +repl-diskless-sync no +repl-diskless-sync-delay 5 +repl-diskless-load disabled +repl-disable-tcp-nodelay no +replica-priority 100 +acllog-max-len 128 +requirepass sk123456 +# 限制内存4GB = 4294967296 bytes +maxmemory 4294967296 +maxmemory-policy allkeys-lfu +lazyfree-lazy-eviction no +lazyfree-lazy-expire no +lazyfree-lazy-server-del no +replica-lazy-flush no +lazyfree-lazy-user-del no +oom-score-adj no +oom-score-adj-values 0 200 800 +appendonly no +appendfilename "appendonly.aof" +appendfsync everysec +no-appendfsync-on-rewrite no +auto-aof-rewrite-percentage 100 +auto-aof-rewrite-min-size 64mb +aof-load-truncated yes +aof-use-rdb-preamble yes +lua-time-limit 5000 +slowlog-log-slower-than 10000 +slowlog-max-len 128 +latency-monitor-threshold 0 +notify-keyspace-events "" +hash-max-ziplist-entries 512 +hash-max-ziplist-value 64 +list-max-ziplist-size -2 +list-compress-depth 0 +set-max-intset-entries 512 +zset-max-ziplist-entries 128 +zset-max-ziplist-value 64 +hll-sparse-max-bytes 3000 +stream-node-max-bytes 4096 +stream-node-max-entries 100 +activerehashing yes +client-output-buffer-limit normal 0 0 0 +client-output-buffer-limit replica 256mb 64mb 60 +client-output-buffer-limit pubsub 32mb 8mb 60 +hz 10 +dynamic-hz yes +aof-rewrite-incremental-fsync yes +rdb-save-incremental-fsync yes +jemalloc-bg-thread yes +EOF + cat << EOF > $redis_install_path/start.sh +#!/bin/bash +#set -x +set -e + +pid=\\\`ps -ef | grep '$redis_install_path/bin/redis-server' | grep -v 'grep' | awk '{print \\\$2}'\\\` +cd $redis_install_path +if [ -z \\\$pid ];then + $redis_install_path/bin/redis-server $redis_install_path/redis.conf + echo 'redis启动成功!' +else + echo 'redis正在运行...' +fi +echo '查看日志: tail -F $redis_install_path/redis.log -n 100' +EOF + # 写文件kill.sh文件 + cat << EOF > $redis_install_path/kill.sh +#!/bin/bash +#set -x +set -e +pid=\\\`ps -ef | grep '$redis_install_path/bin/redis-server' | grep -v 'grep' | awk '{print \\\$2}'\\\` +if [ -z \\\$pid ];then + echo 'redis未运行' +else + ps -ef | grep '$redis_install_path/bin/redis-server' | grep -v 'grep' | awk '{print \\\$2}' | xargs kill + echo 'redis已停止!' +fi +EOF + chmod +x $redis_install_path/start.sh + chmod +x $redis_install_path/kill.sh + fi + " + check::exit_code "$?" "redis" "$host 安装redis环境" "exit" + log::info "[redis]" "redis环境安装成功!" + log::info "[redis]" "启动redis: $redis_install_path/start.sh" + log::info "[redis]" "停止redis: $redis_install_path/kill.sh" +} + ###################################################################################################### # 主调用逻辑 ###################################################################################################### @@ -578,6 +718,7 @@ Flag: -gradle 是否安装gradle环境, 默认: '1' -maven 是否安装maven环境, 默认: '1' -jenkins 是否安装jenkins环境, 默认: '1' + -redis 是否安装redis环境, 默认: '1' Example: env-install-centos.sh init \\ @@ -593,7 +734,8 @@ Example: -java 1 \\ -gradle 0 \\ -maven 0 \\ - -jenkins 0 + -jenkins 0 \\ + -redis 0 \\ EOF exit 1 @@ -649,6 +791,9 @@ while [ "${1:-}" != "" ]; do -jenkins ) shift JENKINS_TAG=${1:-JENKINS_TAG} ;; + -redis ) shift + REDIS_TAG=${1:-REDIS_TAG} + ;; * ) help::usage exit 1 esac @@ -672,6 +817,7 @@ if [[ "${INIT_TAG:-}" == "1" ]]; then [[ "${GRADLE_TAG:-}" == "1" ]] && { init:gradle; } [[ "${MAVEN_TAG:-}" == "1" ]] && { init:maven; } [[ "${JENKINS_TAG:-}" == "1" ]] && { init:jenkins; } + [[ "${REDIS_TAG:-}" == "1" ]] && { init:redis; } else help::usage fi diff --git a/05shengke/03xxljob.groovy b/05shengke/03xxljob.groovy new file mode 100644 index 0000000..8121e07 --- /dev/null +++ b/05shengke/03xxljob.groovy @@ -0,0 +1,32 @@ +//file:noinspection ALL +pipeline { + agent any + + environment { + projectName = 'xxl-job' + } + + stages { + stage('#检查环境') { + steps { + sh """ + java -version + """ + } + } + + stage('#编译项目') { + steps { + sh """ + wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/03xxljob.sh + chmod +x 03xxljob.sh + wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/05shengke/03xxljob-prod.sh + chmod +x 03xxljob-prod.sh + ./03xxljob-prod.sh stop + ./03xxljob.sh pull + ./03xxljob-prod.sh start + """ + } + } + } +} From 5c0b9af80ee29e35aba2e47f42a17a6c8e4430fd Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 15:59:31 +0800 Subject: [PATCH 05/24] 07env-install-centos.sh --- 00base/07env-install-centos.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index 030d866..e326218 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -685,6 +685,11 @@ EOF fi " check::exit_code "$?" "redis" "$host 安装redis环境" "exit" + if [[ "${ADD_USER_TAG:-}" == "1" ]]; then + command::exec "${host}" " + sudo chown -R \$(id -u ${ADD_USER_NAME}):\$(id -g ${ADD_USER_NAME}) ${BASE_DIR}/redis + " + fi log::info "[redis]" "redis环境安装成功!" log::info "[redis]" "启动redis: $redis_install_path/start.sh" log::info "[redis]" "停止redis: $redis_install_path/kill.sh" @@ -735,7 +740,7 @@ Example: -gradle 0 \\ -maven 0 \\ -jenkins 0 \\ - -redis 0 \\ + -redis 0 EOF exit 1 From 034f5cdf7ddd2a7727155a30ad0513453562c8fe Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 16:11:50 +0800 Subject: [PATCH 06/24] 07env-install-centos.sh --- 00base/07env-install-centos.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index e326218..1badb7a 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -568,14 +568,14 @@ function init:redis() { cd ${BASE_DIR}/redis tar -zxvf ${REDIS_FILE_NAME} cd $redis_path - yum -y install gcc - yum -y install centos-release-scl - yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils - scl enable devtoolset-9 bash - echo 'source /opt/rh/devtoolset-9/enable' >> /etc/profile - gcc -v + #yum -y install gcc + #yum -y install centos-release-scl + #yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils + #scl enable devtoolset-9 bash + #echo 'source /opt/rh/devtoolset-9/enable' >> /etc/profile + #gcc -v cd $redis_path - make install PREFIX=$redis_install_path + #make install PREFIX=$redis_install_path # 写文件start.sh文件 cat << EOF > $redis_install_path/redis.conf # bind 127.0.0.1 From e8f9783b6f0c8621cba95daa9146664221b7e1bb Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 16:13:20 +0800 Subject: [PATCH 07/24] 07env-install-centos.sh --- 00base/07env-install-centos.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index 1badb7a..cf12927 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -575,7 +575,7 @@ function init:redis() { #echo 'source /opt/rh/devtoolset-9/enable' >> /etc/profile #gcc -v cd $redis_path - #make install PREFIX=$redis_install_path + make install PREFIX=$redis_install_path # 写文件start.sh文件 cat << EOF > $redis_install_path/redis.conf # bind 127.0.0.1 From abbb70d0c576be5833e698d1787a5f978feb84c2 Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 16:23:31 +0800 Subject: [PATCH 08/24] 07env-install-centos.sh --- 00base/07env-install-centos.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index cf12927..e326218 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -568,12 +568,12 @@ function init:redis() { cd ${BASE_DIR}/redis tar -zxvf ${REDIS_FILE_NAME} cd $redis_path - #yum -y install gcc - #yum -y install centos-release-scl - #yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils - #scl enable devtoolset-9 bash - #echo 'source /opt/rh/devtoolset-9/enable' >> /etc/profile - #gcc -v + yum -y install gcc + yum -y install centos-release-scl + yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils + scl enable devtoolset-9 bash + echo 'source /opt/rh/devtoolset-9/enable' >> /etc/profile + gcc -v cd $redis_path make install PREFIX=$redis_install_path # 写文件start.sh文件 From f43acfc6fe467724c4e0e65cd0364c20480db71c Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 16:27:59 +0800 Subject: [PATCH 09/24] 07env-install-centos.sh --- 00base/07env-install-centos.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index e326218..ee25b16 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -573,6 +573,7 @@ function init:redis() { yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils scl enable devtoolset-9 bash echo 'source /opt/rh/devtoolset-9/enable' >> /etc/profile + source /etc/profile gcc -v cd $redis_path make install PREFIX=$redis_install_path From 841b176fdf20cb46ec10e9c0bfc34bb12d47474e Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 16:34:00 +0800 Subject: [PATCH 10/24] 07env-install-centos.sh --- 00base/07env-install-centos.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index ee25b16..935616f 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -575,6 +575,7 @@ function init:redis() { echo 'source /opt/rh/devtoolset-9/enable' >> /etc/profile source /etc/profile gcc -v + mkdir -p $redis_install_path cd $redis_path make install PREFIX=$redis_install_path # 写文件start.sh文件 From 81909384465a42478ba1135958db4bfbbb572678 Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 16:49:55 +0800 Subject: [PATCH 11/24] 07env-install-centos.sh --- 00base/07env-install-centos.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index 935616f..cf6bfc2 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -622,7 +622,7 @@ lazyfree-lazy-user-del no oom-score-adj no oom-score-adj-values 0 200 800 appendonly no -appendfilename "appendonly.aof" +appendfilename \"appendonly.aof\" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 @@ -633,7 +633,7 @@ lua-time-limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 -notify-keyspace-events "" +notify-keyspace-events \"\" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-size -2 From bfff72dbf9100e79d857f2b12c8197eb43a6451f Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 16:56:26 +0800 Subject: [PATCH 12/24] 07env-install-centos.sh --- 00base/07env-install-centos.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index cf6bfc2..4af9774 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -576,8 +576,11 @@ function init:redis() { source /etc/profile gcc -v mkdir -p $redis_install_path + echo '111' cd $redis_path + echo '222' make install PREFIX=$redis_install_path + echo '333' # 写文件start.sh文件 cat << EOF > $redis_install_path/redis.conf # bind 127.0.0.1 @@ -654,6 +657,7 @@ aof-rewrite-incremental-fsync yes rdb-save-incremental-fsync yes jemalloc-bg-thread yes EOF + echo '444' cat << EOF > $redis_install_path/start.sh #!/bin/bash #set -x @@ -682,8 +686,11 @@ else echo 'redis已停止!' fi EOF + echo '555' chmod +x $redis_install_path/start.sh + echo '666' chmod +x $redis_install_path/kill.sh + echo '777' fi " check::exit_code "$?" "redis" "$host 安装redis环境" "exit" From 0392b999d2e693f69c5a6b72460b3627cb5339b7 Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 17:01:49 +0800 Subject: [PATCH 13/24] 07env-install-centos.sh --- 00base/07env-install-centos.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index 4af9774..2410413 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -573,14 +573,17 @@ function init:redis() { yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils scl enable devtoolset-9 bash echo 'source /opt/rh/devtoolset-9/enable' >> /etc/profile + echo 'ttt-888' source /etc/profile + echo 'ttt-999' gcc -v + echo 'ttt-000' mkdir -p $redis_install_path - echo '111' + echo 'ttt-111' cd $redis_path - echo '222' + echo 'ttt-222' make install PREFIX=$redis_install_path - echo '333' + echo 'ttt-333' # 写文件start.sh文件 cat << EOF > $redis_install_path/redis.conf # bind 127.0.0.1 @@ -657,7 +660,7 @@ aof-rewrite-incremental-fsync yes rdb-save-incremental-fsync yes jemalloc-bg-thread yes EOF - echo '444' + echo 'ttt-444' cat << EOF > $redis_install_path/start.sh #!/bin/bash #set -x @@ -686,11 +689,11 @@ else echo 'redis已停止!' fi EOF - echo '555' + echo 'ttt-555' chmod +x $redis_install_path/start.sh - echo '666' + echo 'ttt-666' chmod +x $redis_install_path/kill.sh - echo '777' + echo 'ttt-777' fi " check::exit_code "$?" "redis" "$host 安装redis环境" "exit" From 94d557dded9b2bb9205f715f1956d04a4284582b Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 17:18:44 +0800 Subject: [PATCH 14/24] 07env-install-centos.sh --- 05shengke/03xxljob.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/05shengke/03xxljob.groovy b/05shengke/03xxljob.groovy index 8121e07..af882ab 100644 --- a/05shengke/03xxljob.groovy +++ b/05shengke/03xxljob.groovy @@ -24,7 +24,7 @@ pipeline { chmod +x 03xxljob-prod.sh ./03xxljob-prod.sh stop ./03xxljob.sh pull - ./03xxljob-prod.sh start + JENKINS_NODE_COOKIE=dontKillMe nohup ./03xxljob-prod.sh start > /dev/null 2>&1 & """ } } From c05173243c38b1070e45855698b01eb96d750a11 Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 17:23:29 +0800 Subject: [PATCH 15/24] 07env-install-centos.sh --- 05shengke/03xxljob.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/05shengke/03xxljob.groovy b/05shengke/03xxljob.groovy index af882ab..3961f3b 100644 --- a/05shengke/03xxljob.groovy +++ b/05shengke/03xxljob.groovy @@ -24,6 +24,7 @@ pipeline { chmod +x 03xxljob-prod.sh ./03xxljob-prod.sh stop ./03xxljob.sh pull + sleep 10s JENKINS_NODE_COOKIE=dontKillMe nohup ./03xxljob-prod.sh start > /dev/null 2>&1 & """ } From a10af2352abbe99a2a7f875d0d9e233ba0e9bc0e Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 17:25:58 +0800 Subject: [PATCH 16/24] 07env-install-centos.sh --- 00base/07env-install-centos.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index 2410413..268108f 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -568,10 +568,15 @@ function init:redis() { cd ${BASE_DIR}/redis tar -zxvf ${REDIS_FILE_NAME} cd $redis_path + echo 'ttt-@@@@@@@@@@@@@111' yum -y install gcc + echo 'ttt-@@@@@@@@@@@@@222' yum -y install centos-release-scl + echo 'ttt-@@@@@@@@@@@@@333' yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils + echo 'ttt-@@@@@@@@@@@@@444' scl enable devtoolset-9 bash + echo 'ttt-777' echo 'source /opt/rh/devtoolset-9/enable' >> /etc/profile echo 'ttt-888' source /etc/profile From 73bdab1af8191e5bd96ccbef5fb22c89027d6bda Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 17:33:07 +0800 Subject: [PATCH 17/24] 07env-install-centos.sh --- 00base/07env-install-centos.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index 268108f..fba704a 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -575,7 +575,7 @@ function init:redis() { echo 'ttt-@@@@@@@@@@@@@333' yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils echo 'ttt-@@@@@@@@@@@@@444' - scl enable devtoolset-9 bash + echo 'ttt-777' echo 'source /opt/rh/devtoolset-9/enable' >> /etc/profile echo 'ttt-888' From 65a2a4a330a60fd9a12b85b30c7c3d4d16085196 Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 17:38:28 +0800 Subject: [PATCH 18/24] 07env-install-centos.sh --- 00base/07env-install-centos.sh | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index fba704a..6ed9ad6 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -568,27 +568,15 @@ function init:redis() { cd ${BASE_DIR}/redis tar -zxvf ${REDIS_FILE_NAME} cd $redis_path - echo 'ttt-@@@@@@@@@@@@@111' yum -y install gcc - echo 'ttt-@@@@@@@@@@@@@222' yum -y install centos-release-scl - echo 'ttt-@@@@@@@@@@@@@333' yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils - echo 'ttt-@@@@@@@@@@@@@444' - - echo 'ttt-777' echo 'source /opt/rh/devtoolset-9/enable' >> /etc/profile - echo 'ttt-888' source /etc/profile - echo 'ttt-999' gcc -v - echo 'ttt-000' mkdir -p $redis_install_path - echo 'ttt-111' cd $redis_path - echo 'ttt-222' make install PREFIX=$redis_install_path - echo 'ttt-333' # 写文件start.sh文件 cat << EOF > $redis_install_path/redis.conf # bind 127.0.0.1 @@ -665,7 +653,6 @@ aof-rewrite-incremental-fsync yes rdb-save-incremental-fsync yes jemalloc-bg-thread yes EOF - echo 'ttt-444' cat << EOF > $redis_install_path/start.sh #!/bin/bash #set -x @@ -694,11 +681,8 @@ else echo 'redis已停止!' fi EOF - echo 'ttt-555' chmod +x $redis_install_path/start.sh - echo 'ttt-666' chmod +x $redis_install_path/kill.sh - echo 'ttt-777' fi " check::exit_code "$?" "redis" "$host 安装redis环境" "exit" From 2476481df287403818df94befc103def37791eb7 Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 17:48:38 +0800 Subject: [PATCH 19/24] 04wms83-prod.sh --- 00base/07env-install-centos.sh | 2 +- 05shengke/04wms83-prod.groovy | 28 +++++ 05shengke/04wms83-prod.sh | 229 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 258 insertions(+), 1 deletion(-) create mode 100644 05shengke/04wms83-prod.groovy create mode 100644 05shengke/04wms83-prod.sh diff --git a/00base/07env-install-centos.sh b/00base/07env-install-centos.sh index 6ed9ad6..82d2b5e 100644 --- a/00base/07env-install-centos.sh +++ b/00base/07env-install-centos.sh @@ -609,7 +609,7 @@ repl-diskless-load disabled repl-disable-tcp-nodelay no replica-priority 100 acllog-max-len 128 -requirepass sk123456 +requirepass admin123456 # 限制内存4GB = 4294967296 bytes maxmemory 4294967296 maxmemory-policy allkeys-lfu diff --git a/05shengke/04wms83-prod.groovy b/05shengke/04wms83-prod.groovy new file mode 100644 index 0000000..c61e50a --- /dev/null +++ b/05shengke/04wms83-prod.groovy @@ -0,0 +1,28 @@ +//file:noinspection ALL +pipeline { + agent any + + environment { + projectName = 'wms8' + } + + stages { + stage('#检查环境') { + steps { + sh """ + java -version + """ + } + } + + stage('#编译项目') { + steps { + sh """ + wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/05shengke/04wms83-prod.sh + chmod +x ./04wms83-prod.sh + JENKINS_NODE_COOKIE=dontKillMe nohup ./04wms83-prod.sh deploy > /dev/null 2>&1 & + """ + } + } + } +} diff --git a/05shengke/04wms83-prod.sh b/05shengke/04wms83-prod.sh new file mode 100644 index 0000000..afac9ee --- /dev/null +++ b/05shengke/04wms83-prod.sh @@ -0,0 +1,229 @@ +#!/bin/bash +#set -x +set -e + +codePath=/home/www/deploy/wms8_shengke +gitUrlArr=( + "http://git.galaxis.yvanui.com/wms8/wms83.git" + "http://git.yvanui.com/lizhiwei/yvan-framework.git" +) + +branchArr=( + "master" + "8.3" +) +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() { + # 构建 wms-biz/bundle + if [ "${needBuild[0]}" != "0" ]; then + echo -e "$echoPrefix cd $codePath/wms-biz/bundle $echoSuffix" + cd "$codePath/wms-biz/bundle" + 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 "wms-biz/bundle 文件未变化" + fi + + # 构建 wms-biz/pda-client + if [ "${needBuild[0]}" != "0" ]; then + echo -e "$echoPrefix cd $codePath/wms-biz/pda-client $echoSuffix" + cd "$codePath/wms-biz/pda-client" + echo -e "$echoPrefix yarn $echoSuffix" + yarn + echo -e "$echoPrefix yarn link yvan-ext-mobile $echoSuffix" + yarn link yvan-ext-mobile + echo -e "$echoPrefix yarn build $echoSuffix" + yarn build + echo "" + else + echo "wms-biz/pda-client 文件未变化" + 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_shengke/wms8_shengke.log +dirPath=/home/www/deploy/wms8_shengke/wms-biz/servo/build/libs/ +serverName=wms8_shengke + +cmd=$1 +profiles=${2:-"prod"} + +#------------------------------------------------------------------- +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../runtime/ $echoSuffix" + cd $dirPath../runtime/ + 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=8101 >>/dev/null 2>&1 & $echoSuffix" + java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./servo-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles --server.port=8101 >>/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 3s + fi + # 移动编译后的文件 + 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 +} + +restartServer() { + pid=$1 + if [ ! -z $pid ];then + stopServer $pid + sleep 3s + fi + startServer +} + +logs() { + tail -F $logPath -n 100 +} + +deployYvanUI() { + bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/01yvan-ext.sh) pull + bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/02yvan-ext-mobile.sh) pull +} + +pid=`ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}'` +# 操作参数: pull deploy restart start stop kill log logs +if [ "$cmd" == "pull" ];then + deployYvanUI + deployPull + if [ -z $pid ];then + echo "$serverName 未运行 | 输入操作参数: pull deploy restart start stop kill log logs" + fi +elif [ "$cmd" == "deploy" ];then + deployYvanUI + 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 deploy restart start stop kill log logs" + else + echo "输入操作参数: pull deploy restart start stop kill log logs" + echo "pid=$pid | $serverName 正在运行... | 查看日志: tail -F $logPath -n 100" + fi +fi + +# 云南圣科 +# bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/05shengke/04wms83-prod.sh) [cmd profiles] From fd8c30f59826a4e115cfb0377eb627cf0cc6ab08 Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 18:01:33 +0800 Subject: [PATCH 20/24] 05api-prod.sh --- 05shengke/05api-prod.groovy | 28 +++++++ 05shengke/05api-prod.sh | 174 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100644 05shengke/05api-prod.groovy create mode 100644 05shengke/05api-prod.sh diff --git a/05shengke/05api-prod.groovy b/05shengke/05api-prod.groovy new file mode 100644 index 0000000..68548c7 --- /dev/null +++ b/05shengke/05api-prod.groovy @@ -0,0 +1,28 @@ +//file:noinspection ALL +pipeline { + agent any + + environment { + projectName = 'wms8-api' + } + + stages { + stage('#检查环境') { + steps { + sh """ + java -version + """ + } + } + + stage('#编译项目') { + steps { + sh """ + wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/05shengke/05api-prod.sh + chmod +x ./05api-prod.sh + JENKINS_NODE_COOKIE=dontKillMe nohup ./05api-prod.sh deploy > /dev/null 2>&1 & + """ + } + } + } +} diff --git a/05shengke/05api-prod.sh b/05shengke/05api-prod.sh new file mode 100644 index 0000000..1642a58 --- /dev/null +++ b/05shengke/05api-prod.sh @@ -0,0 +1,174 @@ +#!/bin/bash +#set -x +set -e + +codePath=/home/www/deploy/wms8_api_shengke +gitUrlArr=( + "http://git.galaxis.yvanui.com/wms8/wms83.git" + "http://git.yvanui.com/lizhiwei/yvan-framework.git" +) + +branchArr=( + "master" + "8.3" +) +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_api_shengke/wms8_api_shengke.log +dirPath=/home/www/deploy/wms8_api_shengke/wms-biz/wms8-api/build/libs/ +serverName=wms8_api_shengke + +cmd=$1 +profiles=${2:-"prod"} + +#------------------------------------------------------------------- +JAVA_MEM_OPTS=" -DappName=${serverName} -server -Xmx1g -Xms1g" +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 -Duser.name=user" +#------------------------------------------------------------------- + +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 ./wms8-api-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles --server.port=8094 >>/dev/null 2>&1 & $echoSuffix" + java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./wms8-api-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles --server.port=8094 >>/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 + echo "###--代码更新完成--------------------------------------------------------------------------###" + echo "" +} + +deployServer() { + pid=$1 + if [ ! -z $pid ];then + stopServer $pid + sleep 3s + fi + deployPull + buildCode + echo "###--代码构建完成--------------------------------------------------------------------------###" + echo "" + startServer +} + +restartServer() { + pid=$1 + if [ ! -z $pid ];then + stopServer $pid + sleep 3s + fi + startServer +} + +logs() { + tail -F $logPath -n 100 +} + +pid=`ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}'` +# 操作参数: deploy restart start stop kill log logs +if [ "$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 未运行 | 输入操作参数: deploy restart start stop kill log logs" + else + echo "输入操作参数: 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/05shengke/05api-prod.sh) [cmd profiles] From 009f5a650a8a83e5bcc991929770a6a7a0d242b6 Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 18:34:54 +0800 Subject: [PATCH 21/24] 04wms83-prod.groovy 05api-prod.groovy --- 05shengke/04wms83-prod.groovy | 5 ++++- 05shengke/05api-prod.groovy | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/05shengke/04wms83-prod.groovy b/05shengke/04wms83-prod.groovy index c61e50a..c09bef0 100644 --- a/05shengke/04wms83-prod.groovy +++ b/05shengke/04wms83-prod.groovy @@ -11,6 +11,7 @@ pipeline { steps { sh """ java -version + gradle -v """ } } @@ -20,8 +21,10 @@ pipeline { sh """ wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/05shengke/04wms83-prod.sh chmod +x ./04wms83-prod.sh - JENKINS_NODE_COOKIE=dontKillMe nohup ./04wms83-prod.sh deploy > /dev/null 2>&1 & + ./04wms83-prod.sh deploy + sleep 5s """ + sh "JENKINS_NODE_COOKIE=dontKillMe nohup ./04wms83-prod.sh restart > /dev/null 2>&1 &" } } } diff --git a/05shengke/05api-prod.groovy b/05shengke/05api-prod.groovy index 68548c7..b220e78 100644 --- a/05shengke/05api-prod.groovy +++ b/05shengke/05api-prod.groovy @@ -11,6 +11,7 @@ pipeline { steps { sh """ java -version + gradle -v """ } } @@ -20,8 +21,10 @@ pipeline { sh """ wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/05shengke/05api-prod.sh chmod +x ./05api-prod.sh - JENKINS_NODE_COOKIE=dontKillMe nohup ./05api-prod.sh deploy > /dev/null 2>&1 & + ./05api-prod.sh deploy + sleep 5s """ + sh "JENKINS_NODE_COOKIE=dontKillMe nohup ./05api-prod.sh restart > /dev/null 2>&1 &" } } } From d42f69d995c56e0a990b792d2c065b8c43148b48 Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 18:39:27 +0800 Subject: [PATCH 22/24] 04wms83-prod.groovy 05api-prod.groovy --- 05shengke/04wms83-prod.groovy | 1 - 05shengke/05api-prod.groovy | 1 - 2 files changed, 2 deletions(-) diff --git a/05shengke/04wms83-prod.groovy b/05shengke/04wms83-prod.groovy index c09bef0..139aab6 100644 --- a/05shengke/04wms83-prod.groovy +++ b/05shengke/04wms83-prod.groovy @@ -22,7 +22,6 @@ pipeline { wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/05shengke/04wms83-prod.sh chmod +x ./04wms83-prod.sh ./04wms83-prod.sh deploy - sleep 5s """ sh "JENKINS_NODE_COOKIE=dontKillMe nohup ./04wms83-prod.sh restart > /dev/null 2>&1 &" } diff --git a/05shengke/05api-prod.groovy b/05shengke/05api-prod.groovy index b220e78..6e52069 100644 --- a/05shengke/05api-prod.groovy +++ b/05shengke/05api-prod.groovy @@ -22,7 +22,6 @@ pipeline { wget -N http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/05shengke/05api-prod.sh chmod +x ./05api-prod.sh ./05api-prod.sh deploy - sleep 5s """ sh "JENKINS_NODE_COOKIE=dontKillMe nohup ./05api-prod.sh restart > /dev/null 2>&1 &" } From 80109158f94382f6972fbb1fe6d9863ff93c6658 Mon Sep 17 00:00:00 2001 From: lizw Date: Mon, 7 Nov 2022 18:47:56 +0800 Subject: [PATCH 23/24] 03xxljob.groovy 04wms83-prod.groovy 05api-prod.groovy --- 05shengke/03xxljob.groovy | 4 +++- 05shengke/04wms83-prod.groovy | 5 ++++- 05shengke/05api-prod.groovy | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/05shengke/03xxljob.groovy b/05shengke/03xxljob.groovy index 3961f3b..5cdb68d 100644 --- a/05shengke/03xxljob.groovy +++ b/05shengke/03xxljob.groovy @@ -24,7 +24,9 @@ pipeline { chmod +x 03xxljob-prod.sh ./03xxljob-prod.sh stop ./03xxljob.sh pull - sleep 10s + """ + sh """ + sleep 3s JENKINS_NODE_COOKIE=dontKillMe nohup ./03xxljob-prod.sh start > /dev/null 2>&1 & """ } diff --git a/05shengke/04wms83-prod.groovy b/05shengke/04wms83-prod.groovy index 139aab6..a9ac465 100644 --- a/05shengke/04wms83-prod.groovy +++ b/05shengke/04wms83-prod.groovy @@ -23,7 +23,10 @@ pipeline { chmod +x ./04wms83-prod.sh ./04wms83-prod.sh deploy """ - sh "JENKINS_NODE_COOKIE=dontKillMe nohup ./04wms83-prod.sh restart > /dev/null 2>&1 &" + sh """ + sleep 3s + JENKINS_NODE_COOKIE=dontKillMe nohup ./04wms83-prod.sh restart > /dev/null 2>&1 & + """ } } } diff --git a/05shengke/05api-prod.groovy b/05shengke/05api-prod.groovy index 6e52069..77e2eab 100644 --- a/05shengke/05api-prod.groovy +++ b/05shengke/05api-prod.groovy @@ -23,7 +23,10 @@ pipeline { chmod +x ./05api-prod.sh ./05api-prod.sh deploy """ - sh "JENKINS_NODE_COOKIE=dontKillMe nohup ./05api-prod.sh restart > /dev/null 2>&1 &" + sh """ + sleep 3s + JENKINS_NODE_COOKIE=dontKillMe nohup ./05api-prod.sh restart > /dev/null 2>&1 & + """ } } } From b7847ee4b6573de8d1427b69ef2c864ef2242657 Mon Sep 17 00:00:00 2001 From: lizw Date: Tue, 8 Nov 2022 16:56:32 +0800 Subject: [PATCH 24/24] 06wms8-test2.sh --- 01dongying_guokang/06wms8-test2.sh | 232 +++++++++++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 01dongying_guokang/06wms8-test2.sh diff --git a/01dongying_guokang/06wms8-test2.sh b/01dongying_guokang/06wms8-test2.sh new file mode 100644 index 0000000..bb7591a --- /dev/null +++ b/01dongying_guokang/06wms8-test2.sh @@ -0,0 +1,232 @@ +#!/bin/bash +#set -x +set -e + +codePath=/home/www/deploy/wms8_dygk +gitUrlArr=( + "http://git.galaxis.yvanui.com/wms8/wms8-bench.git" + "http://git.galaxis.yvanui.com/wms8/wms-core.git" + "http://git.yvanui.com/lizhiwei/yvan-framework.git" +) + +branchArr=( + "dongying_guokang" + "dongying_guokang" + "master" +) +positionArr=( + "." + "wms-core" + "yvan-framework" +) +# 是否需要构建,-1:自动;0:不需要;1:需要 +needBuild=( +"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-biz/bundle + if [ "${needBuild[0]}" != "0" ]; then + echo -e "$echoPrefix cd $codePath/wms-biz/bundle $echoSuffix" + cd "$codePath/wms-biz/bundle" + 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 "wms-biz/bundle 文件未变化" + fi + + # 构建 wms-biz/pda-client + if [ "${needBuild[0]}" != "0" ]; then + echo -e "$echoPrefix cd $codePath/wms-biz/pda-client $echoSuffix" + cd "$codePath/wms-biz/pda-client" + echo -e "$echoPrefix yarn $echoSuffix" + yarn + echo -e "$echoPrefix yarn link yvan-ext-mobile $echoSuffix" + yarn link yvan-ext-mobile + echo -e "$echoPrefix yarn build $echoSuffix" + yarn build + echo "" + else + echo "wms-biz/pda-client 文件未变化" + 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_dygk/wms8_dygk.log +dirPath=/home/www/deploy/wms8_dygk/wms-biz/servo/build/libs/ +serverName=wms8_dygk + +cmd=$1 +profiles=${2:-"test2"} + +#------------------------------------------------------------------- +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../runtime/ $echoSuffix" + cd $dirPath../runtime/ + 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=8096 >>/dev/null 2>&1 & $echoSuffix" + java $JAVA_MEM_OPTS $DATABASE_OPTS $JAVA_OPTS_EXT -jar ./servo-0.0.0-SNAPSHOT.jar --spring.profiles.active=global,$profiles --server.port=8096 >>/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 3s + fi + # 移动编译后的文件 + 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 +} + +restartServer() { + pid=$1 + if [ ! -z $pid ];then + stopServer $pid + sleep 3s + fi + startServer +} + +logs() { + tail -F $logPath -n 100 +} + +deployYvanUI() { + bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/01yvan-ext.sh) pull + bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/00base/02yvan-ext-mobile.sh) pull +} + +pid=`ps -ef | grep "DappName=${serverName}" | grep -v 'grep' | awk '{print $2}'` +# 操作参数: pull deploy restart start stop kill log logs +if [ "$cmd" == "pull" ];then + deployYvanUI + deployPull + if [ -z $pid ];then + echo "$serverName 未运行 | 输入操作参数: pull deploy restart start stop kill log logs" + fi +elif [ "$cmd" == "deploy" ];then + deployYvanUI + 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 deploy restart start stop kill log logs" + else + echo "输入操作参数: pull deploy restart start stop kill log logs" + echo "pid=$pid | $serverName 正在运行... | 查看日志: tail -F $logPath -n 100" + fi +fi + +# bash <(curl -s http://git.yvanui.com/lizhiwei/jztd-deploy/raw/master/01dongying_guokang/06wms8-test2.sh) [cmd profiles]