Skip to content

Commit e5c3ac5

Browse files
author
geekidea
committed
add release-admin.xml assembly
1 parent d798ef6 commit e5c3ac5

File tree

9 files changed

+319
-29
lines changed

9 files changed

+319
-29
lines changed

bootstrap/pom.xml

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
<groupId>io.geekidea.springbootplus</groupId>
4848
<artifactId>system</artifactId>
4949
<version>2.0</version>
50-
<scope>compile</scope>
5150
</dependency>
5251
</dependencies>
5352

distribution/admin/bin/restart.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#! /bin/shell
2+
3+
# Copyright 2019-2029 geekidea(https://github.com/geekidea)
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
#======================================================================
18+
# 项目重启shell脚本
19+
# 先调用shutdown.sh停服
20+
# 然后调用startup.sh启动服务
21+
#
22+
# author: geekidea
23+
# date: 2020-3-28
24+
#======================================================================
25+
26+
# 项目名称
27+
28+
# 停服
29+
sh shutdown.sh
30+
31+
# 启动服务
32+
sh startup.sh

distribution/admin/bin/shutdown.sh

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#! /bin/shell
2+
3+
# Copyright 2019-2029 geekidea(https://github.com/geekidea)
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
#======================================================================
18+
# 项目停服shell脚本
19+
# 通过项目名称查找到PID
20+
# 然后kill -9 pid
21+
#
22+
# author: geekidea
23+
# date: 2020-3-28
24+
#======================================================================
25+
26+
# 项目名称
27+
APPLICATION="${admin.artifact.name}"
28+
29+
# 项目启动jar包名称
30+
APPLICATION_JAR="${APPLICATION}.jar"
31+
32+
PID=$(ps -ef | grep ${APPLICATION_JAR} | grep -v grep | awk '{ print $2 }')
33+
if [ -z "$PID" ]
34+
then
35+
echo ${APPLICATION} is already stopped
36+
else
37+
echo kill ${PID}
38+
kill -9 ${PID}
39+
echo ${APPLICATION} stopped successfully
40+
fi

distribution/admin/bin/startup.sh

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#! /bin/shell
2+
3+
# Copyright 2019-2029 geekidea(https://github.com/geekidea)
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
#======================================================================
18+
# Admin项目启动shell脚本
19+
# config目录: 配置文件目录
20+
# logs目录: 项目运行日志目录
21+
# logs/spring-boot-plus_startup.log: 记录启动日志
22+
# logs/back目录: 项目运行日志备份目录
23+
# nohup后台运行
24+
#
25+
# author: geekidea
26+
# date: 2020-3-28
27+
#======================================================================
28+
29+
# 项目名称
30+
APPLICATION="${admin.artifact.name}"
31+
32+
# 项目启动jar包名称
33+
APPLICATION_JAR="${APPLICATION}.jar"
34+
35+
echo ${APPLICATION_JAR}
36+
37+
# bin目录绝对路径
38+
BIN_PATH=$(cd `dirname $0`; pwd)
39+
40+
41+
# 进入bin目录
42+
cd `dirname $0`
43+
# 返回到上一级项目根目录路径
44+
cd ..
45+
# 打印项目根目录绝对路径
46+
# `pwd` 执行系统命令并获得结果
47+
BASE_PATH=`pwd`
48+
49+
# 外部配置文件绝对目录,如果是目录需要/结尾,也可以直接指定文件
50+
# 如果指定的是目录,spring则会读取目录中的所有配置文件
51+
CONFIG_DIR=${BASE_PATH}"/config/"
52+
53+
# 项目日志输出绝对路径
54+
LOG_DIR=${BASE_PATH}"/logs"
55+
LOG_FILE="${APPLICATION}.log"
56+
LOG_PATH="${LOG_DIR}/${LOG_FILE}"
57+
# 日志备份目录
58+
LOG_BACK_DIR="${LOG_DIR}/back/"
59+
60+
# 项目启动日志输出绝对路径
61+
LOG_STARTUP_PATH="${LOG_DIR}/${APPLICATION}_startup.log"
62+
63+
# 当前时间
64+
NOW=$(date --date='0 days ago' "+%Y-%m-%d-%H-%M-%S")
65+
NOW_PRETTY=$(date --date='0 days ago' "+%Y-%m-%d %H:%M:%S")
66+
67+
# 启动日志
68+
STARTUP_LOG="================================================ ${NOW_PRETTY} ================================================\n"
69+
70+
# 如果logs文件夹不存在,则创建文件夹
71+
if [ ! -d "${LOG_DIR}" ]; then
72+
mkdir "${LOG_DIR}"
73+
fi
74+
75+
# 如果logs/back文件夹不存在,则创建文件夹
76+
if [ ! -d "${LOG_BACK_DIR}" ]; then
77+
mkdir "${LOG_BACK_DIR}"
78+
fi
79+
80+
# 如果项目运行日志存在,则重命名备份
81+
if [ -f "${LOG_PATH}" ]; then
82+
mv ${LOG_PATH} "${LOG_BACK_DIR}/${APPLICATION}_back_${NOW}.log"
83+
fi
84+
85+
# 创建新的项目运行日志
86+
echo "" > ${LOG_PATH}
87+
88+
# 如果项目启动日志不存在,则创建,否则追加
89+
echo ${STARTUP_LOG} >> ${LOG_STARTUP_PATH}
90+
91+
#=======================================================
92+
# 将命令启动相关日志追加到日志文件
93+
#=======================================================
94+
95+
# 输出项目名称
96+
STARTUP_LOG="${STARTUP_LOG}application name: ${APPLICATION}\n"
97+
# 输出jar包名称
98+
STARTUP_LOG="${STARTUP_LOG}application jar name: ${APPLICATION_JAR}\n"
99+
# 输出项目bin路径
100+
STARTUP_LOG="${STARTUP_LOG}application bin path: ${BIN_PATH}\n"
101+
# 输出项目根目录
102+
STARTUP_LOG="${STARTUP_LOG}application root path: ${BASE_PATH}\n"
103+
# 打印日志路径
104+
STARTUP_LOG="${STARTUP_LOG}application log path: ${LOG_PATH}\n"
105+
106+
# 打印启动命令
107+
STARTUP_LOG="${STARTUP_LOG}application background startup command: nohup java -jar ${BASE_PATH}/lib/${APPLICATION_JAR} --spring.config.location=${CONFIG_DIR} > ${LOG_PATH} 2>&1 &\n"
108+
109+
#======================================================================
110+
# 执行启动命令:后台启动项目,并将日志输出到项目根目录下的logs文件夹下
111+
#======================================================================
112+
nohup java -jar ${BASE_PATH}/lib/${APPLICATION_JAR} --spring.config.location=${CONFIG_DIR} > ${LOG_PATH} 2>&1 &
113+
114+
# 进程ID
115+
PID=$(ps -ef | grep ${APPLICATION_JAR} | grep -v grep | awk '{ print $2 }')
116+
STARTUP_LOG="${STARTUP_LOG}application pid: ${PID}\n"
117+
118+
# 启动日志追加到启动日志文件中
119+
echo -e ${STARTUP_LOG} >> ${LOG_STARTUP_PATH}
120+
# 打印启动日志
121+
echo -e ${STARTUP_LOG}
122+
123+
# 打印项目日志
124+
tail -f ${LOG_PATH}

distribution/bin/startup.bat

-25
This file was deleted.

distribution/pom.xml

+36-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<plugins>
5252
<plugin>
5353
<artifactId>maven-assembly-plugin</artifactId>
54-
<version>3.2.0</version>
54+
<version>${maven-assembly-plugin.version}</version>
5555
<configuration>
5656
<finalName>${assembly.name}</finalName>
5757
<descriptors>
@@ -71,6 +71,41 @@
7171
</plugins>
7272
</build>
7373
</profile>
74+
75+
<profile>
76+
<id>release-admin</id>
77+
<build>
78+
<resources>
79+
<resource>
80+
<directory>admin</directory>
81+
<filtering>true</filtering>
82+
<targetPath>admin</targetPath>
83+
</resource>
84+
</resources>
85+
<plugins>
86+
<plugin>
87+
<artifactId>maven-assembly-plugin</artifactId>
88+
<version>${maven-assembly-plugin.version}</version>
89+
<configuration>
90+
<finalName>${assembly.name}-admin</finalName>
91+
<descriptors>
92+
<descriptor>release-admin.xml</descriptor>
93+
</descriptors>
94+
<appendAssemblyId>false</appendAssemblyId>
95+
</configuration>
96+
<executions>
97+
<execution>
98+
<id>make-assembly</id>
99+
<phase>package</phase>
100+
<goals>
101+
<goal>single</goal>
102+
</goals>
103+
</execution>
104+
</executions>
105+
</plugin>
106+
</plugins>
107+
</build>
108+
</profile>
74109
</profiles>
75110

76111
</project>

distribution/release-admin.xml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2019-2029 geekidea(https://github.com/geekidea)
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<assembly>
19+
<id>admin</id>
20+
<includeBaseDirectory>true</includeBaseDirectory>
21+
22+
<formats>
23+
<format>dir</format>
24+
<format>tar.gz</format>
25+
<format>zip</format>
26+
</formats>
27+
28+
<fileSets>
29+
<!--
30+
0755->即用户具有读/写/执行权限,组用户和其它用户具有读写权限;
31+
0644->即用户具有读写权限,组用户和其它用户具有只读权限;
32+
-->
33+
<fileSet>
34+
<directory>target/classes/admin/bin</directory>
35+
<outputDirectory>bin</outputDirectory>
36+
<fileMode>0755</fileMode>
37+
</fileSet>
38+
39+
<fileSet>
40+
<directory>admin/config</directory>
41+
<outputDirectory>config</outputDirectory>
42+
<fileMode>0755</fileMode>
43+
</fileSet>
44+
45+
<fileSet>
46+
<directory>admin/logs</directory>
47+
<outputDirectory>logs</outputDirectory>
48+
<fileMode>0755</fileMode>
49+
</fileSet>
50+
51+
<fileSet>
52+
<directory>../admin/target/classes</directory>
53+
<includes>
54+
<include>application.yml</include>
55+
</includes>
56+
<outputDirectory>config</outputDirectory>
57+
<fileMode>0755</fileMode>
58+
</fileSet>
59+
60+
<fileSet>
61+
<directory>../admin/target</directory>
62+
<includes>
63+
<include>*.jar</include>
64+
</includes>
65+
<outputDirectory>lib</outputDirectory>
66+
<fileMode>0755</fileMode>
67+
</fileSet>
68+
69+
<fileSet>
70+
<directory>../</directory>
71+
<includes>
72+
<include>LICENSE</include>
73+
<include>README.md</include>
74+
</includes>
75+
</fileSet>
76+
</fileSets>
77+
78+
</assembly>

docs/bin/deploy.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,11 @@ fi
8787

8888
# 4. 复制spring-boot-plus-server-assembly.tar.gz到项目同级目录下
8989
# 备份之前的server
90-
9190
if [ ! -d "${SERVER_DIR}-back" ]; then
9291
mkdir ${SERVER_DIR}-back
9392
fi
9493

95-
if [[ $IS_UPDATE == 1 ]]
94+
if [[ -d "${SERVER_DIR}" ]]
9695
then
9796
echo "back ${SERVER_DIR}..."
9897
mv ${SERVER_DIR} ${SERVER_DIR}-back/${SERVER_DIR}-back-"${NOW}"

0 commit comments

Comments
 (0)