Skip to content

Commit f5a8c08

Browse files
author
geekidea
committed
optimization deploy.sh
1 parent bfc72c6 commit f5a8c08

File tree

3 files changed

+38
-37
lines changed

3 files changed

+38
-37
lines changed

distribution/bin/startup.sh

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ echo ${STARTUP_LOG} >> ${LOG_STARTUP_PATH}
9191
#==========================================================================================
9292
# JVM Configuration
9393
# -Xmx1g:设置JVM最大可用内存为1G。
94-
# -Xms1g:设置JVM初始内存41。此值可以设置与-Xmx相同,以避免每次垃圾回收完成后JVM重新分配内存
94+
# -Xms1g:设置JVM初始内存1g。此值可以设置与-Xmx相同,以避免每次垃圾回收完成后JVM重新分配内存
9595
# -Xmn512m:设置年轻代大小为512m。整个JVM内存大小=年轻代大小 + 年老代大小 + 持久代大小。
9696
# 持久代一般固定大小为64m,所以增大年轻代,将会减小年老代大小。此值对系统性能影响较大,Sun官方推荐配置为整个堆的3/8
9797
# -XX:MetaspaceSize=64m:存储class的内存大小,该值越大触发Metaspace GC的时机就越晚
98-
# -XX:MaxMetaspaceSize=320m:限制Metaspace增长的上限,防止因为某些情况导致Metaspace无限的使用本地内存,影响到其他程序
98+
# -XX:MaxMetaspaceSize=256m:限制Metaspace增长的上限,防止因为某些情况导致Metaspace无限的使用本地内存,影响到其他程序
9999
# -XX:-OmitStackTraceInFastThrow:解决重复异常不打印堆栈信息问题
100100
#==========================================================================================
101101
JAVA_OPT="-server -Xms1g -Xmx1g -Xmn512m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=256m"
@@ -139,12 +139,4 @@ echo -e ${STARTUP_LOG} >> ${LOG_STARTUP_PATH}
139139
echo -e ${STARTUP_LOG}
140140

141141
# 打印项目日志
142-
tail -f ${LOG_PATH}
143-
144-
145-
146-
nohup java -jar
147-
/Users/mrliu/github/spring-boot-plus/distribution/target/spring-boot-plus-server/spring-boot-plus/lib/bootstrap-2.0-SNAPSHOT.jar
148-
--spring.config.location=/Users/mrliu/github/spring-boot-plus/distribution/target/spring-boot-plus-server/spring-boot-plus/config/
149-
--logging.config=/Users/mrliu/github/spring-boot-plus/distribution/target/spring-boot-plus-server/spring-boot-plus/config/logback.xml >
150-
/Users/mrliu/github/spring-boot-plus/distribution/target/spring-boot-plus-server/spring-boot-plus/logs/bootstrap-2.0-SNAPSHOT.log 2>&1 &
142+
tail -f ${LOG_PATH}

distribution/release.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,19 @@
1717

1818
<assembly>
1919
<id>server</id>
20+
<includeBaseDirectory>true</includeBaseDirectory>
2021

2122
<formats>
2223
<format>dir</format>
2324
<format>tar.gz</format>
2425
<format>zip</format>
2526
</formats>
2627

27-
<includeBaseDirectory>true</includeBaseDirectory>
28-
2928
<fileSets>
3029
<!--
3130
0755->即用户具有读/写/执行权限,组用户和其它用户具有读写权限;
3231
0644->即用户具有读写权限,组用户和其它用户具有只读权限;
3332
-->
34-
3533
<fileSet>
3634
<directory>target/classes/bin</directory>
3735
<outputDirectory>bin</outputDirectory>

docs/bin/deploy.sh

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
#======================================================================
1818
# 1. 下载或更新spring-boot-plus版本库
1919
# 2. maven打包
20-
# 3. 运行spring-boot-plus
21-
# 4. 访问项目
20+
# 3. 停服
21+
# 4. 备份
22+
# 5. 运行spring-boot-plus
2223
# author: geekidea
2324
# date: 2020-3-25
2425
#======================================================================
@@ -27,16 +28,28 @@ NOW=$(date --date='0 days ago' "+%Y-%m-%d-%H-%M-%S")
2728
echo "${NOW}"
2829
PULL_RESULT=""
2930
IS_UPDATE=0
31+
# 项目名称
32+
PROJECT_NAME="spring-boot-plus"
33+
# 版本库路径
34+
REPO_URL="https://gitee.com/geekidea/spring-boot-plus.git"
35+
# 打包文件名称
36+
ASSEMBLY_NAME="spring-boot-plus-server-2.0.tar.gz"
37+
# 服务目录名称
38+
SERVER_DIR="spring-boot-plus-server-2.0"
39+
# 发布的GIT分支名称
40+
DEPLOY_BRANCH=dev
41+
# 发布的Maven Profile
42+
ACTIVE_PROFILE=test
3043

3144
# 1. 下载或更新spring-boot-plus版本库
3245
# 先判断当前目录下是否有spring-boot-plus目录
3346
# 如果有,则执行git pull
3447
# 如果没有,则clone
35-
if [ ! -d "spring-boot-plus" ]; then
36-
git clone https://gitee.com/geekidea/spring-boot-plus.git
37-
cd spring-boot-plus
48+
if [ ! -d "${PROJECT_NAME}" ]; then
49+
git clone ${REPO_URL}
50+
cd ${PROJECT_NAME}
3851
else
39-
cd spring-boot-plus
52+
cd ${PROJECT_NAME}
4053
# 拉取代码,并获取结果判断,是否有新的代码更新,如果有,则备份之前的server,否则替换
4154
PULL_RESULT=$(git pull)
4255
echo "${PULL_RESULT}"
@@ -50,18 +63,16 @@ fi
5063

5164
pwd
5265

53-
54-
git checkout master
55-
66+
git checkout ${DEPLOY_BRANCH}
5667
git branch
5768

5869
# 2. maven打包
59-
mvn clean install -P release,test
60-
mvn clean package -P release,test
70+
mvn clean install -P release,${ACTIVE_PROFILE}
71+
mvn clean package -P release,${ACTIVE_PROFILE}
6172

6273
pwd
6374
# 判断是否生成成功
64-
if [ ! -f "target/spring-boot-plus-server-assembly.tar.gz" ]; then
75+
if [ ! -f "distribution/target/${ASSEMBLY_NAME}" ]; then
6576
echo "maven build fail"
6677
exit
6778
fi
@@ -70,35 +81,35 @@ fi
7081
cd ..
7182
pwd
7283

73-
if [ -d "spring-boot-plus-server" ]; then
74-
sh spring-boot-plus-server/bin/shutdown.sh
84+
if [ -d "${SERVER_DIR}" ]; then
85+
sh ${SERVER_DIR}/bin/shutdown.sh
7586
fi
7687

7788
# 4. 复制spring-boot-plus-server-assembly.tar.gz到项目同级目录下
7889
# 备份之前的server
7990

80-
if [ ! -d "spring-boot-plus-server-back" ]; then
81-
mkdir spring-boot-plus-server-back
91+
if [ ! -d "${SERVER_DIR}-back" ]; then
92+
mkdir ${SERVER_DIR}-back
8293
fi
8394

8495
if [[ $IS_UPDATE == 1 ]]
8596
then
86-
echo "back spring-boot-plus-server..."
87-
mv spring-boot-plus-server spring-boot-plus-server-back/spring-boot-plus-server-back-"${NOW}"
97+
echo "back ${SERVER_DIR}..."
98+
mv ${SERVER_DIR} ${SERVER_DIR}-back/${SERVER_DIR}-back-"${NOW}"
8899
echo "back success"
89100
fi
90101

91-
echo "copy spring-boot-plus-server-assembly.tar.gz..."
102+
echo "copy ${ASSEMBLY_NAME}..."
92103
# 复制到项目同级目录,如果有,则覆盖
93-
cp -r -f spring-boot-plus/target/spring-boot-plus-server-assembly.tar.gz spring-boot-plus-server-assembly.tar.gz
104+
cp -r -f ${PROJECT_NAME}/distribution/target/${ASSEMBLY_NAME} ${ASSEMBLY_NAME}
94105
echo "copy success"
95106

96107
pwd
97108
# 5. 运行spring-boot-plus
98-
tar -zxvf spring-boot-plus-server-assembly.tar.gz
109+
tar -zxvf ${ASSEMBLY_NAME}
99110
echo "tar.gz decompression success"
100111

101112
pwd
102-
sh spring-boot-plus-server/bin/shutdown.sh
103-
sh spring-boot-plus-server/bin/startup.sh
113+
sh ${SERVER_DIR}/bin/shutdown.sh
114+
sh ${SERVER_DIR}/bin/startup.sh
104115

0 commit comments

Comments
 (0)