251 lines
8.4 KiB
Markdown
251 lines
8.4 KiB
Markdown
|
|
<div align=center><font size=5>众望通科技 研发中心</font></div>
|
|||
|
|
<div align=center><font size=6>YOUFOOL-INCREPACK 架构设计</font></div>
|
|||
|
|
|
|||
|
|
[TOC]
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
## 1 项目说明
|
|||
|
|
|
|||
|
|
YOUFOOL-INCREPACK是一个管理补丁发布的 **工具链**。主要为了解决 **开发环境** 与 **实施环境** 网络隔离情况下,规范Web应用中补丁的升级,同时为Web应用添加校验机制,未经授权的修改无法部署到Web应用中,规范了实施环境的管理。
|
|||
|
|
|
|||
|
|
## 2 主要功能
|
|||
|
|
|
|||
|
|
* 根据配置生成指定范围增量补丁文件;
|
|||
|
|
* 版本管理自动化,对版本号形成强约束管理;
|
|||
|
|
* 向补丁发放授权;
|
|||
|
|
* 补丁升级过程自动化:补丁下载、解压、备份、覆盖、系统关停、启动、升级成功检测;
|
|||
|
|
* Web中间件启动过程校验,未经授权的文件无法部署启动。
|
|||
|
|
|
|||
|
|
## 3 技术设计
|
|||
|
|
|
|||
|
|

|
|||
|
|
|
|||
|
|
YOUFOOL-INCREPACK由四个部分组成:
|
|||
|
|
|
|||
|
|
* PMS
|
|||
|
|
* Increpack-maven-plugin
|
|||
|
|
* Increpack-client
|
|||
|
|
* Increpack-interceptor
|
|||
|
|
|
|||
|
|
### 3.1 PMS
|
|||
|
|
|
|||
|
|
项目管理系统,闭环管理的角色,升级流程的起点与终点:
|
|||
|
|
|
|||
|
|
* 发布的补丁的授权文件,设定版本逐级发布的链路(链路节点参与补丁授权),最后接收现场升级后的完成信息,作为版本发布的闭环节点;
|
|||
|
|
* 负责所有系统版本发布信息的管理;
|
|||
|
|
* 负责所有系统的License管理;
|
|||
|
|
|
|||
|
|
### 3.2 Increpack-maven-plugin
|
|||
|
|
|
|||
|
|
Maven插件,只适用在Maven管理的开发项目中,Package阶段完成补丁的打包。配置 `Git` 仓库信息、Revision信息和版本号信息后,生成特定版本号样式的补丁。
|
|||
|
|
|
|||
|
|
> 补丁名称样例:*aicods_gz-1.0.12-RELEASE-r252.200504.zip*
|
|||
|
|
|
|||
|
|
#### 3.2.1 补丁文件结构
|
|||
|
|
|
|||
|
|
* 工程文件,目录结构遵循约定,与部署环境一致
|
|||
|
|
* incre_config 目录专门存放配置文件信息
|
|||
|
|
* auth文件,补丁的授权信息
|
|||
|
|
* version.json文件,补丁的版本信息
|
|||
|
|
* README.txt文件,补丁的描述信息
|
|||
|
|
|
|||
|
|
#### 3.2.2 版本号说明
|
|||
|
|
|
|||
|
|
补丁版本号示例: ` youfool-pms_v1.0.12_c6303209da_20201011 `
|
|||
|
|
|
|||
|
|
* 项目名称:youfool-pms,按照约定,与POM中 artifactId 一致;
|
|||
|
|
|
|||
|
|
* 版本号: v1.0.12,编号规则(严格递增):
|
|||
|
|
|
|||
|
|
`MajorVersionNumber.MinorVersionNumber.BugFixNumber`
|
|||
|
|
|
|||
|
|
1. `MajorVersionNumber`,主版本号,项目发生重大升级时递增
|
|||
|
|
|
|||
|
|
2. `MinorVersionNumber`,子版本号,项目进行需求变动升级时递增
|
|||
|
|
|
|||
|
|
3. `BugFixNumber`,修正版本号,项目进行Bug修复时递增
|
|||
|
|
|
|||
|
|
* 代码版本号:c6303209da,对应 `GIT` 的 commit SHA-1 编号,增量补丁截止的版本
|
|||
|
|
|
|||
|
|
* 时间序列号:20201011,打包操作的时间描述,2020年10月11日
|
|||
|
|
|
|||
|
|
|
|||
|
|
### 3.3 Increpack-client
|
|||
|
|
|
|||
|
|
客户端负责工具,由实施人员操作。主要用于辅助实施人员完成补丁的升级、回退和一些简单的系统管理功能。具体功能有:
|
|||
|
|
|
|||
|
|
* 补丁授权的校验
|
|||
|
|
* 补丁版本号校验
|
|||
|
|
* 执行补丁文件的覆盖与备份
|
|||
|
|
* 往实施环境写入授权信息
|
|||
|
|
* 应用系统的关闭与启动
|
|||
|
|
* 系统可用性检测
|
|||
|
|
|
|||
|
|
### 3.4 Increpack-interceptor
|
|||
|
|
|
|||
|
|
Web容器拦截器,用于Web容器启动时进行授权校验:
|
|||
|
|
|
|||
|
|
* 计算环境中应用文件的Hash信息是否与auth授权数据一致,如果出现不一致,认为应用文件被篡改,中断系统启动过程;
|
|||
|
|
* 应用的license校验;
|
|||
|
|
* 系统启动的消息发布,发布渠道:企业微信和应用自带的版本发布消息模块。
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
## 4 版本发布流程
|
|||
|
|
|
|||
|
|
### 4.1 版本发布服务器
|
|||
|
|
|
|||
|
|
### 4.2 分支管理
|
|||
|
|
|
|||
|
|
### 4.3 版本号管理
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
## 5 配置说明
|
|||
|
|
|
|||
|
|
### 5.1 工程配置说明
|
|||
|
|
|
|||
|
|
#### 5.1.1 POM配置
|
|||
|
|
|
|||
|
|
1. 引入依赖youfool-increpack-maven-plugin
|
|||
|
|
|
|||
|
|
```xml
|
|||
|
|
<dependency>
|
|||
|
|
<groupId>com.chinaweal.youfool</groupId>
|
|||
|
|
<artifactId>youfool-increpack-maven-plugin</artifactId>
|
|||
|
|
<version>2.0.0-SNAPSHOT</version>
|
|||
|
|
</dependency>
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
2. 在build.plugins节点下配置需要用到的插件(直接拷贝即可)
|
|||
|
|
|
|||
|
|
```xml
|
|||
|
|
<plugins>
|
|||
|
|
<plugin>
|
|||
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|||
|
|
<artifactId>maven-assembly-plugin</artifactId>
|
|||
|
|
<version>3.3.0</version>
|
|||
|
|
<configuration>
|
|||
|
|
<finalName>${project.artifactId}</finalName>
|
|||
|
|
<descriptors>
|
|||
|
|
<descriptor>target/assembly.xml</descriptor>
|
|||
|
|
</descriptors>
|
|||
|
|
</configuration>
|
|||
|
|
<executions>
|
|||
|
|
<execution>
|
|||
|
|
<id>make-assembly</id>
|
|||
|
|
<phase>package</phase>
|
|||
|
|
<goals>
|
|||
|
|
<goal>single</goal>
|
|||
|
|
</goals>
|
|||
|
|
</execution>
|
|||
|
|
</executions>
|
|||
|
|
</plugin>
|
|||
|
|
<plugin>
|
|||
|
|
<groupId>org.codehaus.mojo</groupId>
|
|||
|
|
<artifactId>exec-maven-plugin</artifactId>
|
|||
|
|
<version>1.6.0</version>
|
|||
|
|
<executions>
|
|||
|
|
<execution>
|
|||
|
|
<phase>compile</phase>
|
|||
|
|
<goals>
|
|||
|
|
<goal>java</goal>
|
|||
|
|
</goals>
|
|||
|
|
<configuration>
|
|||
|
|
<mainClass>com.chinaweal.youfool.increpack.maven.IncrePackMain</mainClass>
|
|||
|
|
<arguments>
|
|||
|
|
<argument>${project.artifactId}</argument>
|
|||
|
|
<argument>${project.version}</argument>
|
|||
|
|
</arguments>
|
|||
|
|
<cleanupDaemonThreads>false</cleanupDaemonThreads>
|
|||
|
|
</configuration>
|
|||
|
|
</execution>
|
|||
|
|
<execution>
|
|||
|
|
<id>authMac</id>
|
|||
|
|
<phase>package</phase>
|
|||
|
|
<goals>
|
|||
|
|
<goal>java</goal>
|
|||
|
|
</goals>
|
|||
|
|
<configuration>
|
|||
|
|
<mainClass>com.chinaweal.youfool.increpack.common.AuthPackMain</mainClass>
|
|||
|
|
</configuration>
|
|||
|
|
</execution>
|
|||
|
|
</executions>
|
|||
|
|
</plugin>
|
|||
|
|
</plugins>
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
|
|||
|
|
#### 5.1.2 increpack.xml配置
|
|||
|
|
|
|||
|
|
文件放置在Maven工程根目录
|
|||
|
|
|
|||
|
|
```XML
|
|||
|
|
<increpack>
|
|||
|
|
<!-- 版本服务器接口地址 -->
|
|||
|
|
<increApi>http://172.22.80.91:8086/control/upgradeRecord/getUpgradeByAppIdAndCodeId</increApi>
|
|||
|
|
<!-- 应用ID -->
|
|||
|
|
<appId>d789d196fdb40bdb2df321216da192ff</appId>
|
|||
|
|
<!-- 工程ID -->
|
|||
|
|
<codeId>e53514c7330d9ccbe701a26cf0803243</codeId>
|
|||
|
|
|
|||
|
|
<!--托管服务器服务器配置-->
|
|||
|
|
<code>
|
|||
|
|
<method>git</method> <!--托管的服务器方式 git、svn-->
|
|||
|
|
<url>http://47.107.61.133:3000/chinaweal/fsrl-server.git</url> <!--托管仓库地址-->
|
|||
|
|
<localRepo>D:\chinaweal\gitea-code\fsrl-server_medical</localRepo> <!-- 工程文件所在地址目录 -->
|
|||
|
|
<subRoute>youfool-increpack-maven-plugin-git</subRoute> <!--工程存放的git仓库不是主目录,需要指定路径项目 -->
|
|||
|
|
<!--默认先从increApi获取打包补丁范围可以不填写,当请求失败则再使用-->
|
|||
|
|
<fromCommit>d160c658ccf1e764cb65bc5e59986b1b2b791144</fromCommit> <!-- 起始的版本号 -->
|
|||
|
|
<untilCommit>64575ae03c6406744821bc4cba81b69f9f27181f</untilCommit> <!-- 截止的版本号-->
|
|||
|
|
</code>
|
|||
|
|
|
|||
|
|
<!-- 本地化配置文件,不用打包,以手工操作的方式进行升级 -->
|
|||
|
|
<exclude>
|
|||
|
|
<fileDir>src\main\resources\properties</fileDir>
|
|||
|
|
<file>src\main\resources\spring\JobBySpring.xml</file>
|
|||
|
|
<file>src\main\resources\config.properties</file>
|
|||
|
|
<file>src\main\resources\logback.xml</file>
|
|||
|
|
<file>src\main\resources\backfill\backfill.properties</file>
|
|||
|
|
</exclude>
|
|||
|
|
</increpack>
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
#### 5.1.3 前端工程配置
|
|||
|
|
|
|||
|
|
package.json追加工程信息
|
|||
|
|
|
|||
|
|
```json
|
|||
|
|
{
|
|||
|
|
"appId": "7d7182320870b9f0a36d843ddbb77362",// 应用ID
|
|||
|
|
"codeId": "ec05f963917a612d247f39ec8fc1ba47",//工程ID
|
|||
|
|
"increApi": "http://172.22.80.91:8086/control/upgradeRecord/getUpgradeByAppIdAndCodeId"//版本服务器接口地址
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
vue.config.js 配置引用插件
|
|||
|
|
|
|||
|
|
```javascript
|
|||
|
|
configureWebpack: {
|
|||
|
|
plugins: [
|
|||
|
|
new IncrePack(packageJson)
|
|||
|
|
]
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
## 6 下一步
|
|||
|
|
|
|||
|
|
### 6.1 完善功能
|
|||
|
|
|
|||
|
|
1. 增量打包插件进行调整新建目录专门存放配置文件
|
|||
|
|
2. 增量打包插件,进行记录删除的日志进行移除文件
|
|||
|
|
|
|||
|
|
### 6.2 规划方向
|
|||
|
|
|
|||
|
|
1. Client功能的完整:下载补丁、关停中间件、启动中间件、系统可用性检测、系统版本升级数据管理;
|
|||
|
|
2. 升级的闭环:PMS结合项目实现补丁授权、生产环境升级历史的统一管理。
|