From 7a3fcb3ed7c7fd1f645326958da89089cea3871a Mon Sep 17 00:00:00 2001 From: zhangjf Date: Sun, 22 Feb 2026 14:04:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BD=BF=E7=94=A8Maven=20Assembly?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=A0=87=E5=87=86=E5=8C=96=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 主要更新: - 每个服务打包为独立tar.gz,包含bin/lib/conf目录 - bin目录:启动/停止/重启/状态脚本 - lib目录:服务JAR包及所有依赖 - conf目录:配置文件(application.yml等) 新增文件: - 各模块src/main/assembly/assembly.xml配置 - 各模块src/main/scripts启动脚本 - server-deploy/scripts一键管理脚本 - server-deploy/assembly/assembly.xml模板 更新文档: - 单机部署文档v2.0,说明assembly打包方式 --- .../3.3.2/m2e-lastUpdated.properties | 4 +- .../3.11.0/m2e-lastUpdated.properties | 4 +- .../3.1.1/m2e-lastUpdated.properties | 4 +- .../3.1.1/m2e-lastUpdated.properties | 4 +- .../3.3.0/m2e-lastUpdated.properties | 4 +- .../3.3.1/m2e-lastUpdated.properties | 4 +- .../3.12.1/m2e-lastUpdated.properties | 4 +- .../3.1.2/m2e-lastUpdated.properties | 4 +- .../3.2.0/m2e-lastUpdated.properties | 4 +- doc/单机部署文档.md | 390 +++++++----------- fund-cust/pom.xml | 25 ++ fund-cust/src/main/assembly/assembly.xml | 43 ++ .../src/main/scripts}/restart.sh | 5 +- .../src/main/scripts}/start.sh | 18 +- fund-cust/src/main/scripts/status.sh | 25 ++ .../src/main/scripts}/stop.sh | 13 +- fund-exp/pom.xml | 25 ++ fund-exp/src/main/assembly/assembly.xml | 43 ++ .../src/main/scripts}/restart.sh | 5 +- .../src/main/scripts}/start.sh | 18 +- fund-exp/src/main/scripts/status.sh | 25 ++ .../src/main/scripts}/stop.sh | 13 +- fund-file/pom.xml | 25 ++ fund-file/src/main/assembly/assembly.xml | 43 ++ .../src/main/scripts}/restart.sh | 5 +- .../src/main/scripts}/start.sh | 18 +- fund-file/src/main/scripts/status.sh | 25 ++ .../src/main/scripts}/stop.sh | 13 +- fund-gateway/pom.xml | 25 ++ fund-gateway/src/main/assembly/assembly.xml | 43 ++ fund-gateway/src/main/scripts/restart.sh | 7 + .../src/main/scripts}/start.sh | 18 +- fund-gateway/src/main/scripts/status.sh | 25 ++ fund-gateway/src/main/scripts/stop.sh | 39 ++ fund-proj/pom.xml | 25 ++ fund-proj/src/main/assembly/assembly.xml | 43 ++ fund-proj/src/main/scripts/restart.sh | 7 + .../src/main/scripts}/start.sh | 18 +- fund-proj/src/main/scripts/status.sh | 25 ++ .../src/main/scripts}/stop.sh | 13 +- fund-receipt/pom.xml | 25 ++ fund-receipt/src/main/assembly/assembly.xml | 43 ++ fund-receipt/src/main/scripts/restart.sh | 7 + .../src/main/scripts}/start.sh | 18 +- fund-receipt/src/main/scripts/status.sh | 25 ++ .../src/main/scripts}/stop.sh | 13 +- fund-report/pom.xml | 25 ++ fund-report/src/main/assembly/assembly.xml | 43 ++ fund-report/src/main/scripts/restart.sh | 7 + .../src/main/scripts}/start.sh | 18 +- fund-report/src/main/scripts/status.sh | 25 ++ .../src/main/scripts}/stop.sh | 13 +- fund-req/pom.xml | 25 ++ fund-req/src/main/assembly/assembly.xml | 43 ++ fund-req/src/main/scripts/restart.sh | 7 + .../src/main/scripts}/start.sh | 18 +- fund-req/src/main/scripts/status.sh | 25 ++ .../src/main/scripts}/stop.sh | 13 +- fund-sys/pom.xml | 27 ++ fund-sys/src/main/assembly/assembly.xml | 43 ++ .../src/main/scripts}/restart.sh | 3 +- .../src/main/scripts}/start.sh | 14 +- fund-sys/src/main/scripts/status.sh | 26 ++ .../src/main/scripts}/stop.sh | 5 +- server-deploy/assembly/assembly.xml | 63 +++ server-deploy/fund-cust/restart.sh | 8 - server-deploy/fund-file/restart.sh | 8 - server-deploy/fund-gateway/restart.sh | 8 - server-deploy/fund-receipt/restart.sh | 8 - server-deploy/fund-report/restart.sh | 8 - server-deploy/{ => scripts}/restart-all.sh | 0 server-deploy/scripts/restart.sh | 9 + server-deploy/{ => scripts}/start-all.sh | 6 +- server-deploy/scripts/start.sh | 41 ++ .../{status.sh => scripts/status-all.sh} | 0 server-deploy/scripts/status.sh | 32 ++ server-deploy/{ => scripts}/stop-all.sh | 6 +- .../{fund-gateway => scripts}/stop.sh | 10 +- 78 files changed, 1359 insertions(+), 460 deletions(-) create mode 100644 fund-cust/src/main/assembly/assembly.xml rename {server-deploy/fund-sys => fund-cust/src/main/scripts}/restart.sh (65%) rename {server-deploy/fund-cust => fund-cust/src/main/scripts}/start.sh (66%) create mode 100755 fund-cust/src/main/scripts/status.sh rename {server-deploy/fund-cust => fund-cust/src/main/scripts}/stop.sh (72%) create mode 100644 fund-exp/src/main/assembly/assembly.xml rename {server-deploy/fund-exp => fund-exp/src/main/scripts}/restart.sh (65%) rename {server-deploy/fund-exp => fund-exp/src/main/scripts}/start.sh (66%) create mode 100755 fund-exp/src/main/scripts/status.sh rename {server-deploy/fund-exp => fund-exp/src/main/scripts}/stop.sh (72%) create mode 100644 fund-file/src/main/assembly/assembly.xml rename {server-deploy/fund-proj => fund-file/src/main/scripts}/restart.sh (64%) rename {server-deploy/fund-file => fund-file/src/main/scripts}/start.sh (66%) create mode 100755 fund-file/src/main/scripts/status.sh rename {server-deploy/fund-file => fund-file/src/main/scripts}/stop.sh (72%) create mode 100644 fund-gateway/src/main/assembly/assembly.xml create mode 100755 fund-gateway/src/main/scripts/restart.sh rename {server-deploy/fund-gateway => fund-gateway/src/main/scripts}/start.sh (66%) create mode 100755 fund-gateway/src/main/scripts/status.sh create mode 100755 fund-gateway/src/main/scripts/stop.sh create mode 100644 fund-proj/src/main/assembly/assembly.xml create mode 100755 fund-proj/src/main/scripts/restart.sh rename {server-deploy/fund-proj => fund-proj/src/main/scripts}/start.sh (66%) create mode 100755 fund-proj/src/main/scripts/status.sh rename {server-deploy/fund-proj => fund-proj/src/main/scripts}/stop.sh (72%) create mode 100644 fund-receipt/src/main/assembly/assembly.xml create mode 100755 fund-receipt/src/main/scripts/restart.sh rename {server-deploy/fund-receipt => fund-receipt/src/main/scripts}/start.sh (66%) create mode 100755 fund-receipt/src/main/scripts/status.sh rename {server-deploy/fund-receipt => fund-receipt/src/main/scripts}/stop.sh (71%) create mode 100644 fund-report/src/main/assembly/assembly.xml create mode 100755 fund-report/src/main/scripts/restart.sh rename {server-deploy/fund-report => fund-report/src/main/scripts}/start.sh (66%) create mode 100755 fund-report/src/main/scripts/status.sh rename {server-deploy/fund-report => fund-report/src/main/scripts}/stop.sh (72%) create mode 100644 fund-req/src/main/assembly/assembly.xml create mode 100755 fund-req/src/main/scripts/restart.sh rename {server-deploy/fund-req => fund-req/src/main/scripts}/start.sh (66%) create mode 100755 fund-req/src/main/scripts/status.sh rename {server-deploy/fund-req => fund-req/src/main/scripts}/stop.sh (72%) create mode 100644 fund-sys/src/main/assembly/assembly.xml rename {server-deploy/fund-req => fund-sys/src/main/scripts}/restart.sh (75%) mode change 100755 => 100644 rename {server-deploy/fund-sys => fund-sys/src/main/scripts}/start.sh (69%) mode change 100755 => 100644 create mode 100644 fund-sys/src/main/scripts/status.sh rename {server-deploy/fund-sys => fund-sys/src/main/scripts}/stop.sh (89%) mode change 100755 => 100644 create mode 100644 server-deploy/assembly/assembly.xml delete mode 100755 server-deploy/fund-cust/restart.sh delete mode 100755 server-deploy/fund-file/restart.sh delete mode 100755 server-deploy/fund-gateway/restart.sh delete mode 100755 server-deploy/fund-receipt/restart.sh delete mode 100755 server-deploy/fund-report/restart.sh rename server-deploy/{ => scripts}/restart-all.sh (100%) mode change 100755 => 100644 create mode 100644 server-deploy/scripts/restart.sh rename server-deploy/{ => scripts}/start-all.sh (79%) mode change 100755 => 100644 create mode 100644 server-deploy/scripts/start.sh rename server-deploy/{status.sh => scripts/status-all.sh} (100%) mode change 100755 => 100644 create mode 100644 server-deploy/scripts/status.sh rename server-deploy/{ => scripts}/stop-all.sh (79%) mode change 100755 => 100644 rename server-deploy/{fund-gateway => scripts}/stop.sh (74%) mode change 100755 => 100644 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-clean-plugin/3.3.2/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-clean-plugin/3.3.2/m2e-lastUpdated.properties index e9203dc..3e3f266 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-clean-plugin/3.3.2/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-clean-plugin/3.3.2/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 18:45:42 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771584342966 +#Sun Feb 22 13:58:28 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771739908393 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-compiler-plugin/3.11.0/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-compiler-plugin/3.11.0/m2e-lastUpdated.properties index 0c7863d..0bec93a 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-compiler-plugin/3.11.0/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-compiler-plugin/3.11.0/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 18:45:42 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771584342984 +#Sun Feb 22 13:58:28 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771739908396 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-deploy-plugin/3.1.1/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-deploy-plugin/3.1.1/m2e-lastUpdated.properties index 514a06d..b751229 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-deploy-plugin/3.1.1/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-deploy-plugin/3.1.1/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 18:45:43 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771584343003 +#Sun Feb 22 13:58:28 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771739908400 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-install-plugin/3.1.1/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-install-plugin/3.1.1/m2e-lastUpdated.properties index 7e1cbbb..b751229 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-install-plugin/3.1.1/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-install-plugin/3.1.1/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 18:45:43 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771584343001 +#Sun Feb 22 13:58:28 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771739908400 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-jar-plugin/3.3.0/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-jar-plugin/3.3.0/m2e-lastUpdated.properties index 68abeab..37cd326 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-jar-plugin/3.3.0/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-jar-plugin/3.3.0/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 18:45:42 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771584342991 +#Sun Feb 22 13:58:28 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771739908398 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-resources-plugin/3.3.1/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-resources-plugin/3.3.1/m2e-lastUpdated.properties index 62c7847..57cf7a6 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-resources-plugin/3.3.1/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-resources-plugin/3.3.1/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 18:45:42 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771584342979 +#Sun Feb 22 13:58:28 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771739908394 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-site-plugin/3.12.1/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-site-plugin/3.12.1/m2e-lastUpdated.properties index 69ec72e..2194835 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-site-plugin/3.12.1/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-site-plugin/3.12.1/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 18:45:43 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771584343012 +#Sun Feb 22 13:58:28 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771739908401 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-surefire-plugin/3.1.2/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-surefire-plugin/3.1.2/m2e-lastUpdated.properties index 52e46f3..0e88117 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-surefire-plugin/3.1.2/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-surefire-plugin/3.1.2/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 18:45:42 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771584342989 +#Sun Feb 22 13:58:28 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771739908397 diff --git a/.mvn/repository/org/springframework/boot/spring-boot-maven-plugin/3.2.0/m2e-lastUpdated.properties b/.mvn/repository/org/springframework/boot/spring-boot-maven-plugin/3.2.0/m2e-lastUpdated.properties index 78e21d4..37cd326 100644 --- a/.mvn/repository/org/springframework/boot/spring-boot-maven-plugin/3.2.0/m2e-lastUpdated.properties +++ b/.mvn/repository/org/springframework/boot/spring-boot-maven-plugin/3.2.0/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 18:45:42 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771584342997 +#Sun Feb 22 13:58:28 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771739908398 diff --git a/doc/单机部署文档.md b/doc/单机部署文档.md index 3ea48fd..204c540 100644 --- a/doc/单机部署文档.md +++ b/doc/单机部署文档.md @@ -1,7 +1,7 @@ # 资金服务平台单机部署文档 -> 版本: v1.0 -> 更新日期: 2026-02-20 +> 版本: v2.0 +> 更新日期: 2026-02-22 > 作者: zhangjf --- @@ -70,17 +70,19 @@ /opt/fundplatform/ # 应用根目录 ├── deploy/ # 部署目录 │ ├── fund-gateway/ # Gateway服务 -│ │ ├── fund-gateway.jar # 服务JAR包 -│ │ ├── application.yml # 服务配置文件 -│ │ ├── start.sh # 启动脚本 -│ │ ├── stop.sh # 停止脚本 -│ │ └── restart.sh # 重启脚本 +│ │ ├── bin/ # 脚本目录 +│ │ │ ├── start.sh # 启动脚本 +│ │ │ ├── stop.sh # 停止脚本 +│ │ │ ├── restart.sh # 重启脚本 +│ │ │ └── status.sh # 状态查看脚本 +│ │ ├── lib/ # 依赖JAR目录 +│ │ │ └── fund-gateway.jar # 服务JAR包 +│ │ └── conf/ # 配置文件目录 +│ │ └── application.yml # 服务配置文件 │ ├── fund-sys/ # 系统服务 -│ │ ├── fund-sys.jar -│ │ ├── application.yml -│ │ ├── start.sh -│ │ ├── stop.sh -│ │ └── restart.sh +│ │ ├── bin/ +│ │ ├── lib/ +│ │ └── conf/ │ ├── fund-cust/ # 客户服务 │ ├── fund-proj/ # 项目服务 │ ├── fund-req/ # 需求服务 @@ -92,6 +94,18 @@ │ ├── stop-all.sh # 一键停止所有服务 │ ├── restart-all.sh # 一键重启所有服务 │ └── status.sh # 查看所有服务状态 +├── packages/ # 发布包目录 +│ ├── fund-gateway.tar.gz # Gateway服务发布包 +│ ├── fund-sys.tar.gz # 系统服务发布包 +│ ├── fund-cust.tar.gz # 客户服务发布包 +│ ├── fund-proj.tar.gz # 项目服务发布包 +│ ├── fund-req.tar.gz # 需求服务发布包 +│ ├── fund-exp.tar.gz # 支出服务发布包 +│ ├── fund-receipt.tar.gz # 收款服务发布包 +│ ├── fund-report.tar.gz # 报表服务发布包 +│ ├── fund-file.tar.gz # 文件服务发布包 +│ ├── fund-admin.zip # 管理后台前端发布包 +│ └── fund-mobile.zip # 移动端H5发布包 ├── sql/ # 数据库脚本 │ ├── fund_platform_schema.sql # 表结构 │ └── fund_platform_init.sql # 初始化数据 @@ -347,31 +361,109 @@ mkdir -p /datacfs/applogs/fund-file ### 4.2 编译打包 +项目使用 **Maven Assembly Plugin** 实现标准化打包,每个服务打包为一个独立的 `tar.gz` 文件。 + +#### 4.2.1 后端服务打包 + ```bash # 在开发机上编译打包 -cd /path/to/fundplatform mvn clean package -DskipTests -# 打包结果 -# fund-gateway/target/fund-gateway-0.0.1-SNAPSHOT.jar -# fund-sys/target/fund-sys-0.0.1-SNAPSHOT.jar -# ... +# 打包结果(位于各模块的target目录) +# fund-gateway/target/fund-gateway.tar.gz +# fund-sys/target/fund-sys.tar.gz +# fund-cust/target/fund-cust.tar.gz +# fund-proj/target/fund-proj.tar.gz +# fund-req/target/fund-req.tar.gz +# fund-exp/target/fund-exp.tar.gz +# fund-receipt/target/fund-receipt.tar.gz +# fund-report/target/fund-report.tar.gz +# fund-file/target/fund-file.tar.gz +``` + +#### 4.2.2 打包结构说明 + +每个服务的 `tar.gz` 包解压后包含以下目录结构: + +``` +fund-sys/ +├── bin/ # 脚本目录 +│ ├── start.sh # 启动脚本 +│ ├── stop.sh # 停止脚本 +│ ├── restart.sh # 重启脚本 +│ └── status.sh # 状态查看脚本 +├── lib/ # 依赖JAR目录 +│ └── fund-sys.jar # 服务JAR包(包含所有依赖) +└── conf/ # 配置文件目录 + ├── application.yml # 主配置文件 + ├── application-*.yml # 环境配置文件 + └── logback-spring.xml # 日志配置文件 +``` + +#### 4.2.3 前端打包 + +```bash +# 管理后台打包 +cd fund-admin +npm install +npm run build +# 生成 dist 目录,打包为 fund-admin.zip +zip -r fund-admin.zip dist/ + +# 移动端H5打包 +cd fund-mobile +npm install +npm run build +# 生成 dist 目录,打包为 fund-mobile.zip +zip -r fund-mobile.zip dist/ ``` ### 4.3 上传部署文件 ```bash -# 上传JAR包和配置文件到服务器 -scp fund-gateway/target/fund-gateway-0.0.1-SNAPSHOT.jar user@server:/opt/fundplatform/deploy/fund-gateway/fund-gateway.jar -scp fund-gateway/src/main/resources/application.yml user@server:/opt/fundplatform/deploy/fund-gateway/ +# 创建发布包目录 +mkdir -p /opt/fundplatform/packages -scp fund-sys/target/fund-sys-0.0.1-SNAPSHOT.jar user@server:/opt/fundplatform/deploy/fund-sys/fund-sys.jar -scp fund-sys/src/main/resources/application.yml user@server:/opt/fundplatform/deploy/fund-sys/ +# 上传后端服务发布包 +scp fund-gateway/target/fund-gateway.tar.gz user@server:/opt/fundplatform/packages/ +scp fund-sys/target/fund-sys.tar.gz user@server:/opt/fundplatform/packages/ +scp fund-cust/target/fund-cust.tar.gz user@server:/opt/fundplatform/packages/ +scp fund-proj/target/fund-proj.tar.gz user@server:/opt/fundplatform/packages/ +scp fund-req/target/fund-req.tar.gz user@server:/opt/fundplatform/packages/ +scp fund-exp/target/fund-exp.tar.gz user@server:/opt/fundplatform/packages/ +scp fund-receipt/target/fund-receipt.tar.gz user@server:/opt/fundplatform/packages/ +scp fund-report/target/fund-report.tar.gz user@server:/opt/fundplatform/packages/ +scp fund-file/target/fund-file.tar.gz user@server:/opt/fundplatform/packages/ -# ... 其他服务类似 +# 上传前端发布包 +scp fund-admin.zip user@server:/opt/fundplatform/packages/ +scp fund-mobile.zip user@server:/opt/fundplatform/packages/ ``` -### 4.4 配置文件修改 +### 4.4 解压部署 + +```bash +# 解压后端服务到deploy目录 +cd /opt/fundplatform/packages + +tar -xzf fund-gateway.tar.gz -C /opt/fundplatform/deploy/ +tar -xzf fund-sys.tar.gz -C /opt/fundplatform/deploy/ +tar -xzf fund-cust.tar.gz -C /opt/fundplatform/deploy/ +tar -xzf fund-proj.tar.gz -C /opt/fundplatform/deploy/ +tar -xzf fund-req.tar.gz -C /opt/fundplatform/deploy/ +tar -xzf fund-exp.tar.gz -C /opt/fundplatform/deploy/ +tar -xzf fund-receipt.tar.gz -C /opt/fundplatform/deploy/ +tar -xzf fund-report.tar.gz -C /opt/fundplatform/deploy/ +tar -xzf fund-file.tar.gz -C /opt/fundplatform/deploy/ + +# 上传一键管理脚本到deploy目录 +cp /opt/fundplatform/packages/start-all.sh /opt/fundplatform/deploy/ +cp /opt/fundplatform/packages/stop-all.sh /opt/fundplatform/deploy/ +cp /opt/fundplatform/packages/restart-all.sh /opt/fundplatform/deploy/ +cp /opt/fundplatform/packages/status.sh /opt/fundplatform/deploy/ +``` + +### 4.5 配置文件修改 各服务配置文件需要根据实际环境修改以下配置: @@ -398,253 +490,49 @@ spring: namespace: fund-platform ``` -### 4.5 部署脚本 +### 4.6 服务管理脚本 -每个服务目录下包含以下脚本: +每个服务的 `bin` 目录下包含以下脚本: -#### start.sh - 启动脚本 +| 脚本 | 说明 | +|------|------| +| start.sh | 启动服务 | +| stop.sh | 停止服务 | +| restart.sh | 重启服务 | +| status.sh | 查看服务状态 | + +#### 4.6.1 单服务管理 ```bash -#!/bin/bash -# 服务启动脚本 +# 启动单个服务 +/opt/fundplatform/deploy/fund-sys/bin/start.sh -APP_NAME="fund-gateway" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" -LOG_HOME="/datacfs/applogs/${APP_NAME}" -JAR_FILE="${APP_HOME}/${APP_NAME}.jar" -PID_FILE="${APP_HOME}/${APP_NAME}.pid" +# 停止单个服务 +/opt/fundplatform/deploy/fund-sys/bin/stop.sh -# JVM参数 -JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC" +# 重启单个服务 +/opt/fundplatform/deploy/fund-sys/bin/restart.sh -# 日志参数 -LOG_OPTS="-Dlogging.file.path=${LOG_HOME} -DAPP_NAME=${APP_NAME}" - -# 检查是否已运行 -if [ -f "$PID_FILE" ]; then - PID=$(cat $PID_FILE) - if ps -p $PID > /dev/null 2>&1; then - echo "${APP_NAME} is already running (PID: $PID)" - exit 1 - fi -fi - -# 启动服务 -echo "Starting ${APP_NAME}..." -nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE \ - --spring.config.location=${APP_HOME}/application.yml \ - > /dev/null 2>&1 & - -# 保存PID -echo $! > $PID_FILE -echo "${APP_NAME} started (PID: $(cat $PID_FILE))" +# 查看服务状态 +/opt/fundplatform/deploy/fund-sys/bin/status.sh ``` -#### stop.sh - 停止脚本 +#### 4.6.2 一键管理所有服务 ```bash -#!/bin/bash -# 服务停止脚本 - -APP_NAME="fund-gateway" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" -PID_FILE="${APP_HOME}/${APP_NAME}.pid" - -# 检查是否运行 -if [ ! -f "$PID_FILE" ]; then - echo "${APP_NAME} is not running" - exit 0 -fi - -PID=$(cat $PID_FILE) -if ! ps -p $PID > /dev/null 2>&1; then - echo "${APP_NAME} is not running" - rm -f $PID_FILE - exit 0 -fi - -# 停止服务 -echo "Stopping ${APP_NAME} (PID: $PID)..." -kill $PID - -# 等待停止 -for i in {1..30}; do - if ! ps -p $PID > /dev/null 2>&1; then - break - fi - sleep 1 -done - -# 强制停止 -if ps -p $PID > /dev/null 2>&1; then - echo "Force killing ${APP_NAME}..." - kill -9 $PID -fi - -rm -f $PID_FILE -echo "${APP_NAME} stopped" -``` - -#### restart.sh - 重启脚本 - -```bash -#!/bin/bash -# 服务重启脚本 - -APP_NAME="fund-gateway" -SCRIPT_DIR=$(dirname "$0") - -${SCRIPT_DIR}/stop.sh -sleep 3 -${SCRIPT_DIR}/start.sh -``` - -### 4.6 一键管理脚本 - -#### start-all.sh - 一键启动所有服务 - -```bash -#!/bin/bash # 一键启动所有服务 +/opt/fundplatform/deploy/start-all.sh -DEPLOY_HOME="/opt/fundplatform/deploy" - -# 服务启动顺序(先启动基础服务) -SERVICES=( - "fund-gateway" - "fund-sys" - "fund-cust" - "fund-proj" - "fund-req" - "fund-exp" - "fund-receipt" - "fund-report" - "fund-file" -) - -echo "==========================================" -echo " Starting all services..." -echo "==========================================" - -for service in "${SERVICES[@]}"; do - if [ -f "${DEPLOY_HOME}/${service}/start.sh" ]; then - echo "" - echo "Starting ${service}..." - ${DEPLOY_HOME}/${service}/start.sh - sleep 5 - fi -done - -echo "" -echo "==========================================" -echo " All services started" -echo "==========================================" -${DEPLOY_HOME}/status.sh -``` - -#### stop-all.sh - 一键停止所有服务 - -```bash -#!/bin/bash # 一键停止所有服务 +/opt/fundplatform/deploy/stop-all.sh -DEPLOY_HOME="/opt/fundplatform/deploy" - -# 服务停止顺序(反向停止) -SERVICES=( - "fund-file" - "fund-report" - "fund-receipt" - "fund-exp" - "fund-req" - "fund-proj" - "fund-cust" - "fund-sys" - "fund-gateway" -) - -echo "==========================================" -echo " Stopping all services..." -echo "==========================================" - -for service in "${SERVICES[@]}"; do - if [ -f "${DEPLOY_HOME}/${service}/stop.sh" ]; then - echo "" - echo "Stopping ${service}..." - ${DEPLOY_HOME}/${service}/stop.sh - sleep 2 - fi -done - -echo "" -echo "==========================================" -echo " All services stopped" -echo "==========================================" -``` - -#### restart-all.sh - 一键重启所有服务 - -```bash -#!/bin/bash # 一键重启所有服务 +/opt/fundplatform/deploy/restart-all.sh -DEPLOY_HOME="/opt/fundplatform/deploy" - -${DEPLOY_HOME}/stop-all.sh -echo "" -echo "Waiting 10 seconds..." -sleep 10 -${DEPLOY_HOME}/start-all.sh -``` - -#### status.sh - 查看所有服务状态 - -```bash -#!/bin/bash # 查看所有服务状态 - -DEPLOY_HOME="/opt/fundplatform/deploy" - -SERVICES=( - "fund-gateway:8000" - "fund-sys:8100" - "fund-cust:8200" - "fund-proj:8300" - "fund-req:8400" - "fund-exp:8500" - "fund-receipt:8600" - "fund-report:8700" - "fund-file:8800" -) - -echo "==========================================" -echo " Service Status" -echo "==========================================" -printf "%-20s %-10s %-10s %s\n" "Service" "Port" "Status" "PID" -echo "------------------------------------------" - -for item in "${SERVICES[@]}"; do - service="${item%%:*}" - port="${item##*:}" - pid_file="${DEPLOY_HOME}/${service}/${service}.pid" - - if [ -f "$pid_file" ]; then - PID=$(cat $pid_file) - if ps -p $PID > /dev/null 2>&1; then - printf "%-20s %-10s \033[32m%-10s\033[0m %s\n" "$service" "$port" "RUNNING" "$PID" - else - printf "%-20s %-10s \033[31m%-10s\033[0m %s\n" "$service" "$port" "STOPPED" "-" - fi - else - printf "%-20s %-10s \033[31m%-10s\033[0m %s\n" "$service" "$port" "STOPPED" "-" - fi -done - -echo "==========================================" +/opt/fundplatform/deploy/status.sh ``` ---- - ## 五、部署操作指南 ### 5.1 首次部署 diff --git a/fund-cust/pom.xml b/fund-cust/pom.xml index afb68b7..977a257 100644 --- a/fund-cust/pom.xml +++ b/fund-cust/pom.xml @@ -73,6 +73,31 @@ org.springframework.boot spring-boot-maven-plugin + + ${project.artifactId} + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.6.0 + + + src/main/assembly/assembly.xml + + ${project.artifactId} + false + + + + make-assembly + package + + single + + + diff --git a/fund-cust/src/main/assembly/assembly.xml b/fund-cust/src/main/assembly/assembly.xml new file mode 100644 index 0000000..7a1390e --- /dev/null +++ b/fund-cust/src/main/assembly/assembly.xml @@ -0,0 +1,43 @@ + + bin + + tar.gz + + true + + + + + src/main/scripts + bin + + *.sh + + 0755 + + + + + src/main/resources + conf + + application.yml + application-*.yml + logback-spring.xml + bootstrap.yml + *.properties + + 0644 + + + + + + + lib + true + runtime + 0644 + + + diff --git a/server-deploy/fund-sys/restart.sh b/fund-cust/src/main/scripts/restart.sh similarity index 65% rename from server-deploy/fund-sys/restart.sh rename to fund-cust/src/main/scripts/restart.sh index c92d966..3566bb8 100755 --- a/server-deploy/fund-sys/restart.sh +++ b/fund-cust/src/main/scripts/restart.sh @@ -1,6 +1,5 @@ -#!/bin/bash -# fund-sys 服务重启脚本 - +#\!/bin/bash +# 服务重启脚本 SCRIPT_DIR=$(dirname "$0") ${SCRIPT_DIR}/stop.sh diff --git a/server-deploy/fund-cust/start.sh b/fund-cust/src/main/scripts/start.sh similarity index 66% rename from server-deploy/fund-cust/start.sh rename to fund-cust/src/main/scripts/start.sh index 26b56de..abbbccb 100755 --- a/server-deploy/fund-cust/start.sh +++ b/fund-cust/src/main/scripts/start.sh @@ -1,10 +1,9 @@ -#!/bin/bash -# fund-cust 服务启动脚本 - +#\!/bin/bash +# 服务启动脚本 APP_NAME="fund-cust" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" LOG_HOME="/datacfs/applogs/${APP_NAME}" -JAR_FILE="${APP_HOME}/${APP_NAME}.jar" +JAR_FILE="${APP_HOME}/lib/${APP_NAME}.jar" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # JVM参数 @@ -13,6 +12,9 @@ JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200" # 日志参数 LOG_OPTS="-Dlogging.file.path=${LOG_HOME} -DAPP_NAME=${APP_NAME}" +# 配置文件路径 +CONFIG_OPTS="--spring.config.location=${APP_HOME}/conf/application.yml" + # 检查是否已运行 if [ -f "$PID_FILE" ]; then PID=$(cat $PID_FILE) @@ -27,10 +29,8 @@ mkdir -p ${LOG_HOME} # 启动服务 echo "Starting ${APP_NAME}..." -nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE \ - --spring.config.location=${APP_HOME}/application.yml \ - > /dev/null 2>&1 & +nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE $CONFIG_OPTS > /dev/null 2>&1 & # 保存PID -echo $! > $PID_FILE +echo $\! > $PID_FILE echo "${APP_NAME} started (PID: $(cat $PID_FILE))" diff --git a/fund-cust/src/main/scripts/status.sh b/fund-cust/src/main/scripts/status.sh new file mode 100755 index 0000000..617b873 --- /dev/null +++ b/fund-cust/src/main/scripts/status.sh @@ -0,0 +1,25 @@ +#\!/bin/bash +# 查看服务状态 +APP_NAME="fund-cust" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" +PID_FILE="${APP_HOME}/${APP_NAME}.pid" + +echo "==========================================" +echo " Service: ${APP_NAME}" +echo "==========================================" + +if [ -f "$PID_FILE" ]; then + PID=$(cat $PID_FILE) + if ps -p $PID > /dev/null 2>&1; then + echo -e "Status: \033[32mRUNNING\033[0m" + echo "PID: ${PID}" + ps -p $PID -o pid,ppid,%cpu,%mem,etime,cmd --no-headers 2>/dev/null + else + echo -e "Status: \033[31mSTOPPED\033[0m (stale PID file)" + rm -f $PID_FILE + fi +else + echo -e "Status: \033[31mSTOPPED\033[0m" +fi + +echo "==========================================" diff --git a/server-deploy/fund-cust/stop.sh b/fund-cust/src/main/scripts/stop.sh similarity index 72% rename from server-deploy/fund-cust/stop.sh rename to fund-cust/src/main/scripts/stop.sh index 9e85bcc..9d4bccd 100755 --- a/server-deploy/fund-cust/stop.sh +++ b/fund-cust/src/main/scripts/stop.sh @@ -1,18 +1,17 @@ -#!/bin/bash -# fund-cust 服务停止脚本 - +#\!/bin/bash +# 服务停止脚本 APP_NAME="fund-cust" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # 检查是否运行 -if [ ! -f "$PID_FILE" ]; then +if [ \! -f "$PID_FILE" ]; then echo "${APP_NAME} is not running" exit 0 fi PID=$(cat $PID_FILE) -if ! ps -p $PID > /dev/null 2>&1; then +if \! ps -p $PID > /dev/null 2>&1; then echo "${APP_NAME} is not running" rm -f $PID_FILE exit 0 @@ -24,7 +23,7 @@ kill $PID # 等待停止 for i in {1..30}; do - if ! ps -p $PID > /dev/null 2>&1; then + if \! ps -p $PID > /dev/null 2>&1; then break fi sleep 1 diff --git a/fund-exp/pom.xml b/fund-exp/pom.xml index 44b2b15..a9be5e8 100644 --- a/fund-exp/pom.xml +++ b/fund-exp/pom.xml @@ -65,6 +65,31 @@ org.springframework.boot spring-boot-maven-plugin + + ${project.artifactId} + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.6.0 + + + src/main/assembly/assembly.xml + + ${project.artifactId} + false + + + + make-assembly + package + + single + + + diff --git a/fund-exp/src/main/assembly/assembly.xml b/fund-exp/src/main/assembly/assembly.xml new file mode 100644 index 0000000..7a1390e --- /dev/null +++ b/fund-exp/src/main/assembly/assembly.xml @@ -0,0 +1,43 @@ + + bin + + tar.gz + + true + + + + + src/main/scripts + bin + + *.sh + + 0755 + + + + + src/main/resources + conf + + application.yml + application-*.yml + logback-spring.xml + bootstrap.yml + *.properties + + 0644 + + + + + + + lib + true + runtime + 0644 + + + diff --git a/server-deploy/fund-exp/restart.sh b/fund-exp/src/main/scripts/restart.sh similarity index 65% rename from server-deploy/fund-exp/restart.sh rename to fund-exp/src/main/scripts/restart.sh index e149e74..3566bb8 100755 --- a/server-deploy/fund-exp/restart.sh +++ b/fund-exp/src/main/scripts/restart.sh @@ -1,6 +1,5 @@ -#!/bin/bash -# fund-exp 服务重启脚本 - +#\!/bin/bash +# 服务重启脚本 SCRIPT_DIR=$(dirname "$0") ${SCRIPT_DIR}/stop.sh diff --git a/server-deploy/fund-exp/start.sh b/fund-exp/src/main/scripts/start.sh similarity index 66% rename from server-deploy/fund-exp/start.sh rename to fund-exp/src/main/scripts/start.sh index e6eec67..ef8578f 100755 --- a/server-deploy/fund-exp/start.sh +++ b/fund-exp/src/main/scripts/start.sh @@ -1,10 +1,9 @@ -#!/bin/bash -# fund-exp 服务启动脚本 - +#\!/bin/bash +# 服务启动脚本 APP_NAME="fund-exp" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" LOG_HOME="/datacfs/applogs/${APP_NAME}" -JAR_FILE="${APP_HOME}/${APP_NAME}.jar" +JAR_FILE="${APP_HOME}/lib/${APP_NAME}.jar" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # JVM参数 @@ -13,6 +12,9 @@ JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200" # 日志参数 LOG_OPTS="-Dlogging.file.path=${LOG_HOME} -DAPP_NAME=${APP_NAME}" +# 配置文件路径 +CONFIG_OPTS="--spring.config.location=${APP_HOME}/conf/application.yml" + # 检查是否已运行 if [ -f "$PID_FILE" ]; then PID=$(cat $PID_FILE) @@ -27,10 +29,8 @@ mkdir -p ${LOG_HOME} # 启动服务 echo "Starting ${APP_NAME}..." -nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE \ - --spring.config.location=${APP_HOME}/application.yml \ - > /dev/null 2>&1 & +nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE $CONFIG_OPTS > /dev/null 2>&1 & # 保存PID -echo $! > $PID_FILE +echo $\! > $PID_FILE echo "${APP_NAME} started (PID: $(cat $PID_FILE))" diff --git a/fund-exp/src/main/scripts/status.sh b/fund-exp/src/main/scripts/status.sh new file mode 100755 index 0000000..2f5b466 --- /dev/null +++ b/fund-exp/src/main/scripts/status.sh @@ -0,0 +1,25 @@ +#\!/bin/bash +# 查看服务状态 +APP_NAME="fund-exp" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" +PID_FILE="${APP_HOME}/${APP_NAME}.pid" + +echo "==========================================" +echo " Service: ${APP_NAME}" +echo "==========================================" + +if [ -f "$PID_FILE" ]; then + PID=$(cat $PID_FILE) + if ps -p $PID > /dev/null 2>&1; then + echo -e "Status: \033[32mRUNNING\033[0m" + echo "PID: ${PID}" + ps -p $PID -o pid,ppid,%cpu,%mem,etime,cmd --no-headers 2>/dev/null + else + echo -e "Status: \033[31mSTOPPED\033[0m (stale PID file)" + rm -f $PID_FILE + fi +else + echo -e "Status: \033[31mSTOPPED\033[0m" +fi + +echo "==========================================" diff --git a/server-deploy/fund-exp/stop.sh b/fund-exp/src/main/scripts/stop.sh similarity index 72% rename from server-deploy/fund-exp/stop.sh rename to fund-exp/src/main/scripts/stop.sh index 61ed676..022be58 100755 --- a/server-deploy/fund-exp/stop.sh +++ b/fund-exp/src/main/scripts/stop.sh @@ -1,18 +1,17 @@ -#!/bin/bash -# fund-exp 服务停止脚本 - +#\!/bin/bash +# 服务停止脚本 APP_NAME="fund-exp" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # 检查是否运行 -if [ ! -f "$PID_FILE" ]; then +if [ \! -f "$PID_FILE" ]; then echo "${APP_NAME} is not running" exit 0 fi PID=$(cat $PID_FILE) -if ! ps -p $PID > /dev/null 2>&1; then +if \! ps -p $PID > /dev/null 2>&1; then echo "${APP_NAME} is not running" rm -f $PID_FILE exit 0 @@ -24,7 +23,7 @@ kill $PID # 等待停止 for i in {1..30}; do - if ! ps -p $PID > /dev/null 2>&1; then + if \! ps -p $PID > /dev/null 2>&1; then break fi sleep 1 diff --git a/fund-file/pom.xml b/fund-file/pom.xml index cf2dc31..4aaf07a 100644 --- a/fund-file/pom.xml +++ b/fund-file/pom.xml @@ -71,6 +71,31 @@ org.springframework.boot spring-boot-maven-plugin + + ${project.artifactId} + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.6.0 + + + src/main/assembly/assembly.xml + + ${project.artifactId} + false + + + + make-assembly + package + + single + + + diff --git a/fund-file/src/main/assembly/assembly.xml b/fund-file/src/main/assembly/assembly.xml new file mode 100644 index 0000000..7a1390e --- /dev/null +++ b/fund-file/src/main/assembly/assembly.xml @@ -0,0 +1,43 @@ + + bin + + tar.gz + + true + + + + + src/main/scripts + bin + + *.sh + + 0755 + + + + + src/main/resources + conf + + application.yml + application-*.yml + logback-spring.xml + bootstrap.yml + *.properties + + 0644 + + + + + + + lib + true + runtime + 0644 + + + diff --git a/server-deploy/fund-proj/restart.sh b/fund-file/src/main/scripts/restart.sh similarity index 64% rename from server-deploy/fund-proj/restart.sh rename to fund-file/src/main/scripts/restart.sh index 50daba4..3566bb8 100755 --- a/server-deploy/fund-proj/restart.sh +++ b/fund-file/src/main/scripts/restart.sh @@ -1,6 +1,5 @@ -#!/bin/bash -# fund-proj 服务重启脚本 - +#\!/bin/bash +# 服务重启脚本 SCRIPT_DIR=$(dirname "$0") ${SCRIPT_DIR}/stop.sh diff --git a/server-deploy/fund-file/start.sh b/fund-file/src/main/scripts/start.sh similarity index 66% rename from server-deploy/fund-file/start.sh rename to fund-file/src/main/scripts/start.sh index 719ca6e..2ac8c3a 100755 --- a/server-deploy/fund-file/start.sh +++ b/fund-file/src/main/scripts/start.sh @@ -1,10 +1,9 @@ -#!/bin/bash -# fund-file 服务启动脚本 - +#\!/bin/bash +# 服务启动脚本 APP_NAME="fund-file" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" LOG_HOME="/datacfs/applogs/${APP_NAME}" -JAR_FILE="${APP_HOME}/${APP_NAME}.jar" +JAR_FILE="${APP_HOME}/lib/${APP_NAME}.jar" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # JVM参数 @@ -13,6 +12,9 @@ JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200" # 日志参数 LOG_OPTS="-Dlogging.file.path=${LOG_HOME} -DAPP_NAME=${APP_NAME}" +# 配置文件路径 +CONFIG_OPTS="--spring.config.location=${APP_HOME}/conf/application.yml" + # 检查是否已运行 if [ -f "$PID_FILE" ]; then PID=$(cat $PID_FILE) @@ -27,10 +29,8 @@ mkdir -p ${LOG_HOME} # 启动服务 echo "Starting ${APP_NAME}..." -nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE \ - --spring.config.location=${APP_HOME}/application.yml \ - > /dev/null 2>&1 & +nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE $CONFIG_OPTS > /dev/null 2>&1 & # 保存PID -echo $! > $PID_FILE +echo $\! > $PID_FILE echo "${APP_NAME} started (PID: $(cat $PID_FILE))" diff --git a/fund-file/src/main/scripts/status.sh b/fund-file/src/main/scripts/status.sh new file mode 100755 index 0000000..e15e698 --- /dev/null +++ b/fund-file/src/main/scripts/status.sh @@ -0,0 +1,25 @@ +#\!/bin/bash +# 查看服务状态 +APP_NAME="fund-file" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" +PID_FILE="${APP_HOME}/${APP_NAME}.pid" + +echo "==========================================" +echo " Service: ${APP_NAME}" +echo "==========================================" + +if [ -f "$PID_FILE" ]; then + PID=$(cat $PID_FILE) + if ps -p $PID > /dev/null 2>&1; then + echo -e "Status: \033[32mRUNNING\033[0m" + echo "PID: ${PID}" + ps -p $PID -o pid,ppid,%cpu,%mem,etime,cmd --no-headers 2>/dev/null + else + echo -e "Status: \033[31mSTOPPED\033[0m (stale PID file)" + rm -f $PID_FILE + fi +else + echo -e "Status: \033[31mSTOPPED\033[0m" +fi + +echo "==========================================" diff --git a/server-deploy/fund-file/stop.sh b/fund-file/src/main/scripts/stop.sh similarity index 72% rename from server-deploy/fund-file/stop.sh rename to fund-file/src/main/scripts/stop.sh index 1287792..b0c51e0 100755 --- a/server-deploy/fund-file/stop.sh +++ b/fund-file/src/main/scripts/stop.sh @@ -1,18 +1,17 @@ -#!/bin/bash -# fund-file 服务停止脚本 - +#\!/bin/bash +# 服务停止脚本 APP_NAME="fund-file" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # 检查是否运行 -if [ ! -f "$PID_FILE" ]; then +if [ \! -f "$PID_FILE" ]; then echo "${APP_NAME} is not running" exit 0 fi PID=$(cat $PID_FILE) -if ! ps -p $PID > /dev/null 2>&1; then +if \! ps -p $PID > /dev/null 2>&1; then echo "${APP_NAME} is not running" rm -f $PID_FILE exit 0 @@ -24,7 +23,7 @@ kill $PID # 等待停止 for i in {1..30}; do - if ! ps -p $PID > /dev/null 2>&1; then + if \! ps -p $PID > /dev/null 2>&1; then break fi sleep 1 diff --git a/fund-gateway/pom.xml b/fund-gateway/pom.xml index 1044488..94d39ec 100644 --- a/fund-gateway/pom.xml +++ b/fund-gateway/pom.xml @@ -76,6 +76,31 @@ org.springframework.boot spring-boot-maven-plugin + + ${project.artifactId} + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.6.0 + + + src/main/assembly/assembly.xml + + ${project.artifactId} + false + + + + make-assembly + package + + single + + + diff --git a/fund-gateway/src/main/assembly/assembly.xml b/fund-gateway/src/main/assembly/assembly.xml new file mode 100644 index 0000000..7a1390e --- /dev/null +++ b/fund-gateway/src/main/assembly/assembly.xml @@ -0,0 +1,43 @@ + + bin + + tar.gz + + true + + + + + src/main/scripts + bin + + *.sh + + 0755 + + + + + src/main/resources + conf + + application.yml + application-*.yml + logback-spring.xml + bootstrap.yml + *.properties + + 0644 + + + + + + + lib + true + runtime + 0644 + + + diff --git a/fund-gateway/src/main/scripts/restart.sh b/fund-gateway/src/main/scripts/restart.sh new file mode 100755 index 0000000..3566bb8 --- /dev/null +++ b/fund-gateway/src/main/scripts/restart.sh @@ -0,0 +1,7 @@ +#\!/bin/bash +# 服务重启脚本 +SCRIPT_DIR=$(dirname "$0") + +${SCRIPT_DIR}/stop.sh +sleep 3 +${SCRIPT_DIR}/start.sh diff --git a/server-deploy/fund-gateway/start.sh b/fund-gateway/src/main/scripts/start.sh similarity index 66% rename from server-deploy/fund-gateway/start.sh rename to fund-gateway/src/main/scripts/start.sh index 5d6e406..126f2e6 100755 --- a/server-deploy/fund-gateway/start.sh +++ b/fund-gateway/src/main/scripts/start.sh @@ -1,10 +1,9 @@ -#!/bin/bash -# fund-gateway 服务启动脚本 - +#\!/bin/bash +# 服务启动脚本 APP_NAME="fund-gateway" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" LOG_HOME="/datacfs/applogs/${APP_NAME}" -JAR_FILE="${APP_HOME}/${APP_NAME}.jar" +JAR_FILE="${APP_HOME}/lib/${APP_NAME}.jar" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # JVM参数 @@ -13,6 +12,9 @@ JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200" # 日志参数 LOG_OPTS="-Dlogging.file.path=${LOG_HOME} -DAPP_NAME=${APP_NAME}" +# 配置文件路径 +CONFIG_OPTS="--spring.config.location=${APP_HOME}/conf/application.yml" + # 检查是否已运行 if [ -f "$PID_FILE" ]; then PID=$(cat $PID_FILE) @@ -27,10 +29,8 @@ mkdir -p ${LOG_HOME} # 启动服务 echo "Starting ${APP_NAME}..." -nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE \ - --spring.config.location=${APP_HOME}/application.yml \ - > /dev/null 2>&1 & +nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE $CONFIG_OPTS > /dev/null 2>&1 & # 保存PID -echo $! > $PID_FILE +echo $\! > $PID_FILE echo "${APP_NAME} started (PID: $(cat $PID_FILE))" diff --git a/fund-gateway/src/main/scripts/status.sh b/fund-gateway/src/main/scripts/status.sh new file mode 100755 index 0000000..329b2ac --- /dev/null +++ b/fund-gateway/src/main/scripts/status.sh @@ -0,0 +1,25 @@ +#\!/bin/bash +# 查看服务状态 +APP_NAME="fund-gateway" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" +PID_FILE="${APP_HOME}/${APP_NAME}.pid" + +echo "==========================================" +echo " Service: ${APP_NAME}" +echo "==========================================" + +if [ -f "$PID_FILE" ]; then + PID=$(cat $PID_FILE) + if ps -p $PID > /dev/null 2>&1; then + echo -e "Status: \033[32mRUNNING\033[0m" + echo "PID: ${PID}" + ps -p $PID -o pid,ppid,%cpu,%mem,etime,cmd --no-headers 2>/dev/null + else + echo -e "Status: \033[31mSTOPPED\033[0m (stale PID file)" + rm -f $PID_FILE + fi +else + echo -e "Status: \033[31mSTOPPED\033[0m" +fi + +echo "==========================================" diff --git a/fund-gateway/src/main/scripts/stop.sh b/fund-gateway/src/main/scripts/stop.sh new file mode 100755 index 0000000..12c5500 --- /dev/null +++ b/fund-gateway/src/main/scripts/stop.sh @@ -0,0 +1,39 @@ +#\!/bin/bash +# 服务停止脚本 +APP_NAME="fund-gateway" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" +PID_FILE="${APP_HOME}/${APP_NAME}.pid" + +# 检查是否运行 +if [ \! -f "$PID_FILE" ]; then + echo "${APP_NAME} is not running" + exit 0 +fi + +PID=$(cat $PID_FILE) +if \! ps -p $PID > /dev/null 2>&1; then + echo "${APP_NAME} is not running" + rm -f $PID_FILE + exit 0 +fi + +# 停止服务 +echo "Stopping ${APP_NAME} (PID: $PID)..." +kill $PID + +# 等待停止 +for i in {1..30}; do + if \! ps -p $PID > /dev/null 2>&1; then + break + fi + sleep 1 +done + +# 强制停止 +if ps -p $PID > /dev/null 2>&1; then + echo "Force killing ${APP_NAME}..." + kill -9 $PID +fi + +rm -f $PID_FILE +echo "${APP_NAME} stopped" diff --git a/fund-proj/pom.xml b/fund-proj/pom.xml index 956c47f..cdc8cde 100644 --- a/fund-proj/pom.xml +++ b/fund-proj/pom.xml @@ -65,6 +65,31 @@ org.springframework.boot spring-boot-maven-plugin + + ${project.artifactId} + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.6.0 + + + src/main/assembly/assembly.xml + + ${project.artifactId} + false + + + + make-assembly + package + + single + + + diff --git a/fund-proj/src/main/assembly/assembly.xml b/fund-proj/src/main/assembly/assembly.xml new file mode 100644 index 0000000..7a1390e --- /dev/null +++ b/fund-proj/src/main/assembly/assembly.xml @@ -0,0 +1,43 @@ + + bin + + tar.gz + + true + + + + + src/main/scripts + bin + + *.sh + + 0755 + + + + + src/main/resources + conf + + application.yml + application-*.yml + logback-spring.xml + bootstrap.yml + *.properties + + 0644 + + + + + + + lib + true + runtime + 0644 + + + diff --git a/fund-proj/src/main/scripts/restart.sh b/fund-proj/src/main/scripts/restart.sh new file mode 100755 index 0000000..3566bb8 --- /dev/null +++ b/fund-proj/src/main/scripts/restart.sh @@ -0,0 +1,7 @@ +#\!/bin/bash +# 服务重启脚本 +SCRIPT_DIR=$(dirname "$0") + +${SCRIPT_DIR}/stop.sh +sleep 3 +${SCRIPT_DIR}/start.sh diff --git a/server-deploy/fund-proj/start.sh b/fund-proj/src/main/scripts/start.sh similarity index 66% rename from server-deploy/fund-proj/start.sh rename to fund-proj/src/main/scripts/start.sh index cad537c..6dfd484 100755 --- a/server-deploy/fund-proj/start.sh +++ b/fund-proj/src/main/scripts/start.sh @@ -1,10 +1,9 @@ -#!/bin/bash -# fund-proj 服务启动脚本 - +#\!/bin/bash +# 服务启动脚本 APP_NAME="fund-proj" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" LOG_HOME="/datacfs/applogs/${APP_NAME}" -JAR_FILE="${APP_HOME}/${APP_NAME}.jar" +JAR_FILE="${APP_HOME}/lib/${APP_NAME}.jar" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # JVM参数 @@ -13,6 +12,9 @@ JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200" # 日志参数 LOG_OPTS="-Dlogging.file.path=${LOG_HOME} -DAPP_NAME=${APP_NAME}" +# 配置文件路径 +CONFIG_OPTS="--spring.config.location=${APP_HOME}/conf/application.yml" + # 检查是否已运行 if [ -f "$PID_FILE" ]; then PID=$(cat $PID_FILE) @@ -27,10 +29,8 @@ mkdir -p ${LOG_HOME} # 启动服务 echo "Starting ${APP_NAME}..." -nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE \ - --spring.config.location=${APP_HOME}/application.yml \ - > /dev/null 2>&1 & +nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE $CONFIG_OPTS > /dev/null 2>&1 & # 保存PID -echo $! > $PID_FILE +echo $\! > $PID_FILE echo "${APP_NAME} started (PID: $(cat $PID_FILE))" diff --git a/fund-proj/src/main/scripts/status.sh b/fund-proj/src/main/scripts/status.sh new file mode 100755 index 0000000..46d392e --- /dev/null +++ b/fund-proj/src/main/scripts/status.sh @@ -0,0 +1,25 @@ +#\!/bin/bash +# 查看服务状态 +APP_NAME="fund-proj" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" +PID_FILE="${APP_HOME}/${APP_NAME}.pid" + +echo "==========================================" +echo " Service: ${APP_NAME}" +echo "==========================================" + +if [ -f "$PID_FILE" ]; then + PID=$(cat $PID_FILE) + if ps -p $PID > /dev/null 2>&1; then + echo -e "Status: \033[32mRUNNING\033[0m" + echo "PID: ${PID}" + ps -p $PID -o pid,ppid,%cpu,%mem,etime,cmd --no-headers 2>/dev/null + else + echo -e "Status: \033[31mSTOPPED\033[0m (stale PID file)" + rm -f $PID_FILE + fi +else + echo -e "Status: \033[31mSTOPPED\033[0m" +fi + +echo "==========================================" diff --git a/server-deploy/fund-proj/stop.sh b/fund-proj/src/main/scripts/stop.sh similarity index 72% rename from server-deploy/fund-proj/stop.sh rename to fund-proj/src/main/scripts/stop.sh index f15f475..b63515d 100755 --- a/server-deploy/fund-proj/stop.sh +++ b/fund-proj/src/main/scripts/stop.sh @@ -1,18 +1,17 @@ -#!/bin/bash -# fund-proj 服务停止脚本 - +#\!/bin/bash +# 服务停止脚本 APP_NAME="fund-proj" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # 检查是否运行 -if [ ! -f "$PID_FILE" ]; then +if [ \! -f "$PID_FILE" ]; then echo "${APP_NAME} is not running" exit 0 fi PID=$(cat $PID_FILE) -if ! ps -p $PID > /dev/null 2>&1; then +if \! ps -p $PID > /dev/null 2>&1; then echo "${APP_NAME} is not running" rm -f $PID_FILE exit 0 @@ -24,7 +23,7 @@ kill $PID # 等待停止 for i in {1..30}; do - if ! ps -p $PID > /dev/null 2>&1; then + if \! ps -p $PID > /dev/null 2>&1; then break fi sleep 1 diff --git a/fund-receipt/pom.xml b/fund-receipt/pom.xml index 6cf0356..773e25a 100644 --- a/fund-receipt/pom.xml +++ b/fund-receipt/pom.xml @@ -65,6 +65,31 @@ org.springframework.boot spring-boot-maven-plugin + + ${project.artifactId} + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.6.0 + + + src/main/assembly/assembly.xml + + ${project.artifactId} + false + + + + make-assembly + package + + single + + + diff --git a/fund-receipt/src/main/assembly/assembly.xml b/fund-receipt/src/main/assembly/assembly.xml new file mode 100644 index 0000000..7a1390e --- /dev/null +++ b/fund-receipt/src/main/assembly/assembly.xml @@ -0,0 +1,43 @@ + + bin + + tar.gz + + true + + + + + src/main/scripts + bin + + *.sh + + 0755 + + + + + src/main/resources + conf + + application.yml + application-*.yml + logback-spring.xml + bootstrap.yml + *.properties + + 0644 + + + + + + + lib + true + runtime + 0644 + + + diff --git a/fund-receipt/src/main/scripts/restart.sh b/fund-receipt/src/main/scripts/restart.sh new file mode 100755 index 0000000..3566bb8 --- /dev/null +++ b/fund-receipt/src/main/scripts/restart.sh @@ -0,0 +1,7 @@ +#\!/bin/bash +# 服务重启脚本 +SCRIPT_DIR=$(dirname "$0") + +${SCRIPT_DIR}/stop.sh +sleep 3 +${SCRIPT_DIR}/start.sh diff --git a/server-deploy/fund-receipt/start.sh b/fund-receipt/src/main/scripts/start.sh similarity index 66% rename from server-deploy/fund-receipt/start.sh rename to fund-receipt/src/main/scripts/start.sh index e4f5f94..4948290 100755 --- a/server-deploy/fund-receipt/start.sh +++ b/fund-receipt/src/main/scripts/start.sh @@ -1,10 +1,9 @@ -#!/bin/bash -# fund-receipt 服务启动脚本 - +#\!/bin/bash +# 服务启动脚本 APP_NAME="fund-receipt" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" LOG_HOME="/datacfs/applogs/${APP_NAME}" -JAR_FILE="${APP_HOME}/${APP_NAME}.jar" +JAR_FILE="${APP_HOME}/lib/${APP_NAME}.jar" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # JVM参数 @@ -13,6 +12,9 @@ JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200" # 日志参数 LOG_OPTS="-Dlogging.file.path=${LOG_HOME} -DAPP_NAME=${APP_NAME}" +# 配置文件路径 +CONFIG_OPTS="--spring.config.location=${APP_HOME}/conf/application.yml" + # 检查是否已运行 if [ -f "$PID_FILE" ]; then PID=$(cat $PID_FILE) @@ -27,10 +29,8 @@ mkdir -p ${LOG_HOME} # 启动服务 echo "Starting ${APP_NAME}..." -nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE \ - --spring.config.location=${APP_HOME}/application.yml \ - > /dev/null 2>&1 & +nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE $CONFIG_OPTS > /dev/null 2>&1 & # 保存PID -echo $! > $PID_FILE +echo $\! > $PID_FILE echo "${APP_NAME} started (PID: $(cat $PID_FILE))" diff --git a/fund-receipt/src/main/scripts/status.sh b/fund-receipt/src/main/scripts/status.sh new file mode 100755 index 0000000..ed5085e --- /dev/null +++ b/fund-receipt/src/main/scripts/status.sh @@ -0,0 +1,25 @@ +#\!/bin/bash +# 查看服务状态 +APP_NAME="fund-receipt" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" +PID_FILE="${APP_HOME}/${APP_NAME}.pid" + +echo "==========================================" +echo " Service: ${APP_NAME}" +echo "==========================================" + +if [ -f "$PID_FILE" ]; then + PID=$(cat $PID_FILE) + if ps -p $PID > /dev/null 2>&1; then + echo -e "Status: \033[32mRUNNING\033[0m" + echo "PID: ${PID}" + ps -p $PID -o pid,ppid,%cpu,%mem,etime,cmd --no-headers 2>/dev/null + else + echo -e "Status: \033[31mSTOPPED\033[0m (stale PID file)" + rm -f $PID_FILE + fi +else + echo -e "Status: \033[31mSTOPPED\033[0m" +fi + +echo "==========================================" diff --git a/server-deploy/fund-receipt/stop.sh b/fund-receipt/src/main/scripts/stop.sh similarity index 71% rename from server-deploy/fund-receipt/stop.sh rename to fund-receipt/src/main/scripts/stop.sh index bd7f994..6e828d9 100755 --- a/server-deploy/fund-receipt/stop.sh +++ b/fund-receipt/src/main/scripts/stop.sh @@ -1,18 +1,17 @@ -#!/bin/bash -# fund-receipt 服务停止脚本 - +#\!/bin/bash +# 服务停止脚本 APP_NAME="fund-receipt" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # 检查是否运行 -if [ ! -f "$PID_FILE" ]; then +if [ \! -f "$PID_FILE" ]; then echo "${APP_NAME} is not running" exit 0 fi PID=$(cat $PID_FILE) -if ! ps -p $PID > /dev/null 2>&1; then +if \! ps -p $PID > /dev/null 2>&1; then echo "${APP_NAME} is not running" rm -f $PID_FILE exit 0 @@ -24,7 +23,7 @@ kill $PID # 等待停止 for i in {1..30}; do - if ! ps -p $PID > /dev/null 2>&1; then + if \! ps -p $PID > /dev/null 2>&1; then break fi sleep 1 diff --git a/fund-report/pom.xml b/fund-report/pom.xml index 558bcd8..260dccf 100644 --- a/fund-report/pom.xml +++ b/fund-report/pom.xml @@ -70,6 +70,31 @@ org.springframework.boot spring-boot-maven-plugin + + ${project.artifactId} + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.6.0 + + + src/main/assembly/assembly.xml + + ${project.artifactId} + false + + + + make-assembly + package + + single + + + diff --git a/fund-report/src/main/assembly/assembly.xml b/fund-report/src/main/assembly/assembly.xml new file mode 100644 index 0000000..7a1390e --- /dev/null +++ b/fund-report/src/main/assembly/assembly.xml @@ -0,0 +1,43 @@ + + bin + + tar.gz + + true + + + + + src/main/scripts + bin + + *.sh + + 0755 + + + + + src/main/resources + conf + + application.yml + application-*.yml + logback-spring.xml + bootstrap.yml + *.properties + + 0644 + + + + + + + lib + true + runtime + 0644 + + + diff --git a/fund-report/src/main/scripts/restart.sh b/fund-report/src/main/scripts/restart.sh new file mode 100755 index 0000000..3566bb8 --- /dev/null +++ b/fund-report/src/main/scripts/restart.sh @@ -0,0 +1,7 @@ +#\!/bin/bash +# 服务重启脚本 +SCRIPT_DIR=$(dirname "$0") + +${SCRIPT_DIR}/stop.sh +sleep 3 +${SCRIPT_DIR}/start.sh diff --git a/server-deploy/fund-report/start.sh b/fund-report/src/main/scripts/start.sh similarity index 66% rename from server-deploy/fund-report/start.sh rename to fund-report/src/main/scripts/start.sh index ee06249..e523201 100755 --- a/server-deploy/fund-report/start.sh +++ b/fund-report/src/main/scripts/start.sh @@ -1,10 +1,9 @@ -#!/bin/bash -# fund-report 服务启动脚本 - +#\!/bin/bash +# 服务启动脚本 APP_NAME="fund-report" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" LOG_HOME="/datacfs/applogs/${APP_NAME}" -JAR_FILE="${APP_HOME}/${APP_NAME}.jar" +JAR_FILE="${APP_HOME}/lib/${APP_NAME}.jar" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # JVM参数 @@ -13,6 +12,9 @@ JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200" # 日志参数 LOG_OPTS="-Dlogging.file.path=${LOG_HOME} -DAPP_NAME=${APP_NAME}" +# 配置文件路径 +CONFIG_OPTS="--spring.config.location=${APP_HOME}/conf/application.yml" + # 检查是否已运行 if [ -f "$PID_FILE" ]; then PID=$(cat $PID_FILE) @@ -27,10 +29,8 @@ mkdir -p ${LOG_HOME} # 启动服务 echo "Starting ${APP_NAME}..." -nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE \ - --spring.config.location=${APP_HOME}/application.yml \ - > /dev/null 2>&1 & +nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE $CONFIG_OPTS > /dev/null 2>&1 & # 保存PID -echo $! > $PID_FILE +echo $\! > $PID_FILE echo "${APP_NAME} started (PID: $(cat $PID_FILE))" diff --git a/fund-report/src/main/scripts/status.sh b/fund-report/src/main/scripts/status.sh new file mode 100755 index 0000000..c9f0a03 --- /dev/null +++ b/fund-report/src/main/scripts/status.sh @@ -0,0 +1,25 @@ +#\!/bin/bash +# 查看服务状态 +APP_NAME="fund-report" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" +PID_FILE="${APP_HOME}/${APP_NAME}.pid" + +echo "==========================================" +echo " Service: ${APP_NAME}" +echo "==========================================" + +if [ -f "$PID_FILE" ]; then + PID=$(cat $PID_FILE) + if ps -p $PID > /dev/null 2>&1; then + echo -e "Status: \033[32mRUNNING\033[0m" + echo "PID: ${PID}" + ps -p $PID -o pid,ppid,%cpu,%mem,etime,cmd --no-headers 2>/dev/null + else + echo -e "Status: \033[31mSTOPPED\033[0m (stale PID file)" + rm -f $PID_FILE + fi +else + echo -e "Status: \033[31mSTOPPED\033[0m" +fi + +echo "==========================================" diff --git a/server-deploy/fund-report/stop.sh b/fund-report/src/main/scripts/stop.sh similarity index 72% rename from server-deploy/fund-report/stop.sh rename to fund-report/src/main/scripts/stop.sh index 481bfdb..a621827 100755 --- a/server-deploy/fund-report/stop.sh +++ b/fund-report/src/main/scripts/stop.sh @@ -1,18 +1,17 @@ -#!/bin/bash -# fund-report 服务停止脚本 - +#\!/bin/bash +# 服务停止脚本 APP_NAME="fund-report" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # 检查是否运行 -if [ ! -f "$PID_FILE" ]; then +if [ \! -f "$PID_FILE" ]; then echo "${APP_NAME} is not running" exit 0 fi PID=$(cat $PID_FILE) -if ! ps -p $PID > /dev/null 2>&1; then +if \! ps -p $PID > /dev/null 2>&1; then echo "${APP_NAME} is not running" rm -f $PID_FILE exit 0 @@ -24,7 +23,7 @@ kill $PID # 等待停止 for i in {1..30}; do - if ! ps -p $PID > /dev/null 2>&1; then + if \! ps -p $PID > /dev/null 2>&1; then break fi sleep 1 diff --git a/fund-req/pom.xml b/fund-req/pom.xml index a07dbc8..d2bf30c 100644 --- a/fund-req/pom.xml +++ b/fund-req/pom.xml @@ -65,6 +65,31 @@ org.springframework.boot spring-boot-maven-plugin + + ${project.artifactId} + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.6.0 + + + src/main/assembly/assembly.xml + + ${project.artifactId} + false + + + + make-assembly + package + + single + + + diff --git a/fund-req/src/main/assembly/assembly.xml b/fund-req/src/main/assembly/assembly.xml new file mode 100644 index 0000000..7a1390e --- /dev/null +++ b/fund-req/src/main/assembly/assembly.xml @@ -0,0 +1,43 @@ + + bin + + tar.gz + + true + + + + + src/main/scripts + bin + + *.sh + + 0755 + + + + + src/main/resources + conf + + application.yml + application-*.yml + logback-spring.xml + bootstrap.yml + *.properties + + 0644 + + + + + + + lib + true + runtime + 0644 + + + diff --git a/fund-req/src/main/scripts/restart.sh b/fund-req/src/main/scripts/restart.sh new file mode 100755 index 0000000..3566bb8 --- /dev/null +++ b/fund-req/src/main/scripts/restart.sh @@ -0,0 +1,7 @@ +#\!/bin/bash +# 服务重启脚本 +SCRIPT_DIR=$(dirname "$0") + +${SCRIPT_DIR}/stop.sh +sleep 3 +${SCRIPT_DIR}/start.sh diff --git a/server-deploy/fund-req/start.sh b/fund-req/src/main/scripts/start.sh similarity index 66% rename from server-deploy/fund-req/start.sh rename to fund-req/src/main/scripts/start.sh index f52d2a6..253f253 100755 --- a/server-deploy/fund-req/start.sh +++ b/fund-req/src/main/scripts/start.sh @@ -1,10 +1,9 @@ -#!/bin/bash -# fund-req 服务启动脚本 - +#\!/bin/bash +# 服务启动脚本 APP_NAME="fund-req" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" LOG_HOME="/datacfs/applogs/${APP_NAME}" -JAR_FILE="${APP_HOME}/${APP_NAME}.jar" +JAR_FILE="${APP_HOME}/lib/${APP_NAME}.jar" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # JVM参数 @@ -13,6 +12,9 @@ JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200" # 日志参数 LOG_OPTS="-Dlogging.file.path=${LOG_HOME} -DAPP_NAME=${APP_NAME}" +# 配置文件路径 +CONFIG_OPTS="--spring.config.location=${APP_HOME}/conf/application.yml" + # 检查是否已运行 if [ -f "$PID_FILE" ]; then PID=$(cat $PID_FILE) @@ -27,10 +29,8 @@ mkdir -p ${LOG_HOME} # 启动服务 echo "Starting ${APP_NAME}..." -nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE \ - --spring.config.location=${APP_HOME}/application.yml \ - > /dev/null 2>&1 & +nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE $CONFIG_OPTS > /dev/null 2>&1 & # 保存PID -echo $! > $PID_FILE +echo $\! > $PID_FILE echo "${APP_NAME} started (PID: $(cat $PID_FILE))" diff --git a/fund-req/src/main/scripts/status.sh b/fund-req/src/main/scripts/status.sh new file mode 100755 index 0000000..47b364c --- /dev/null +++ b/fund-req/src/main/scripts/status.sh @@ -0,0 +1,25 @@ +#\!/bin/bash +# 查看服务状态 +APP_NAME="fund-req" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" +PID_FILE="${APP_HOME}/${APP_NAME}.pid" + +echo "==========================================" +echo " Service: ${APP_NAME}" +echo "==========================================" + +if [ -f "$PID_FILE" ]; then + PID=$(cat $PID_FILE) + if ps -p $PID > /dev/null 2>&1; then + echo -e "Status: \033[32mRUNNING\033[0m" + echo "PID: ${PID}" + ps -p $PID -o pid,ppid,%cpu,%mem,etime,cmd --no-headers 2>/dev/null + else + echo -e "Status: \033[31mSTOPPED\033[0m (stale PID file)" + rm -f $PID_FILE + fi +else + echo -e "Status: \033[31mSTOPPED\033[0m" +fi + +echo "==========================================" diff --git a/server-deploy/fund-req/stop.sh b/fund-req/src/main/scripts/stop.sh similarity index 72% rename from server-deploy/fund-req/stop.sh rename to fund-req/src/main/scripts/stop.sh index 1af735e..0fabbae 100755 --- a/server-deploy/fund-req/stop.sh +++ b/fund-req/src/main/scripts/stop.sh @@ -1,18 +1,17 @@ -#!/bin/bash -# fund-req 服务停止脚本 - +#\!/bin/bash +# 服务停止脚本 APP_NAME="fund-req" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # 检查是否运行 -if [ ! -f "$PID_FILE" ]; then +if [ \! -f "$PID_FILE" ]; then echo "${APP_NAME} is not running" exit 0 fi PID=$(cat $PID_FILE) -if ! ps -p $PID > /dev/null 2>&1; then +if \! ps -p $PID > /dev/null 2>&1; then echo "${APP_NAME} is not running" rm -f $PID_FILE exit 0 @@ -24,7 +23,7 @@ kill $PID # 等待停止 for i in {1..30}; do - if ! ps -p $PID > /dev/null 2>&1; then + if \! ps -p $PID > /dev/null 2>&1; then break fi sleep 1 diff --git a/fund-sys/pom.xml b/fund-sys/pom.xml index 279e0b8..043f5eb 100644 --- a/fund-sys/pom.xml +++ b/fund-sys/pom.xml @@ -109,9 +109,36 @@ + org.springframework.boot spring-boot-maven-plugin + + ${project.artifactId} + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.6.0 + + + src/main/assembly/assembly.xml + + ${project.artifactId} + false + + + + make-assembly + package + + single + + + diff --git a/fund-sys/src/main/assembly/assembly.xml b/fund-sys/src/main/assembly/assembly.xml new file mode 100644 index 0000000..7a1390e --- /dev/null +++ b/fund-sys/src/main/assembly/assembly.xml @@ -0,0 +1,43 @@ + + bin + + tar.gz + + true + + + + + src/main/scripts + bin + + *.sh + + 0755 + + + + + src/main/resources + conf + + application.yml + application-*.yml + logback-spring.xml + bootstrap.yml + *.properties + + 0644 + + + + + + + lib + true + runtime + 0644 + + + diff --git a/server-deploy/fund-req/restart.sh b/fund-sys/src/main/scripts/restart.sh old mode 100755 new mode 100644 similarity index 75% rename from server-deploy/fund-req/restart.sh rename to fund-sys/src/main/scripts/restart.sh index 561420f..ad8a749 --- a/server-deploy/fund-req/restart.sh +++ b/fund-sys/src/main/scripts/restart.sh @@ -1,6 +1,5 @@ #!/bin/bash -# fund-req 服务重启脚本 - +# 服务重启脚本 SCRIPT_DIR=$(dirname "$0") ${SCRIPT_DIR}/stop.sh diff --git a/server-deploy/fund-sys/start.sh b/fund-sys/src/main/scripts/start.sh old mode 100755 new mode 100644 similarity index 69% rename from server-deploy/fund-sys/start.sh rename to fund-sys/src/main/scripts/start.sh index 6f1660d..845dbbe --- a/server-deploy/fund-sys/start.sh +++ b/fund-sys/src/main/scripts/start.sh @@ -1,10 +1,9 @@ #!/bin/bash -# fund-sys 服务启动脚本 - +# 服务启动脚本 APP_NAME="fund-sys" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" LOG_HOME="/datacfs/applogs/${APP_NAME}" -JAR_FILE="${APP_HOME}/${APP_NAME}.jar" +JAR_FILE="${APP_HOME}/lib/${APP_NAME}.jar" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # JVM参数 @@ -13,6 +12,9 @@ JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200" # 日志参数 LOG_OPTS="-Dlogging.file.path=${LOG_HOME} -DAPP_NAME=${APP_NAME}" +# 配置文件路径 +CONFIG_OPTS="--spring.config.location=${APP_HOME}/conf/application.yml" + # 检查是否已运行 if [ -f "$PID_FILE" ]; then PID=$(cat $PID_FILE) @@ -27,9 +29,7 @@ mkdir -p ${LOG_HOME} # 启动服务 echo "Starting ${APP_NAME}..." -nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE \ - --spring.config.location=${APP_HOME}/application.yml \ - > /dev/null 2>&1 & +nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE $CONFIG_OPTS > /dev/null 2>&1 & # 保存PID echo $! > $PID_FILE diff --git a/fund-sys/src/main/scripts/status.sh b/fund-sys/src/main/scripts/status.sh new file mode 100644 index 0000000..78b156e --- /dev/null +++ b/fund-sys/src/main/scripts/status.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# 查看服务状态 +APP_NAME="fund-sys" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" +PID_FILE="${APP_HOME}/${APP_NAME}.pid" + +echo "==========================================" +echo " Service: ${APP_NAME}" +echo "==========================================" + +if [ -f "$PID_FILE" ]; then + PID=$(cat $PID_FILE) + if ps -p $PID > /dev/null 2>&1; then + echo -e "Status: \033[32mRUNNING\033[0m" + echo "PID: ${PID}" + # 显示进程信息 + ps -p $PID -o pid,ppid,%cpu,%mem,etime,cmd --no-headers 2>/dev/null + else + echo -e "Status: \033[31mSTOPPED\033[0m (stale PID file)" + rm -f $PID_FILE + fi +else + echo -e "Status: \033[31mSTOPPED\033[0m" +fi + +echo "==========================================" diff --git a/server-deploy/fund-sys/stop.sh b/fund-sys/src/main/scripts/stop.sh old mode 100755 new mode 100644 similarity index 89% rename from server-deploy/fund-sys/stop.sh rename to fund-sys/src/main/scripts/stop.sh index a7b3a4d..5271a69 --- a/server-deploy/fund-sys/stop.sh +++ b/fund-sys/src/main/scripts/stop.sh @@ -1,8 +1,7 @@ #!/bin/bash -# fund-sys 服务停止脚本 - +# 服务停止脚本 APP_NAME="fund-sys" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" +APP_HOME="$(cd "$(dirname "$0")/.." && pwd)" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # 检查是否运行 diff --git a/server-deploy/assembly/assembly.xml b/server-deploy/assembly/assembly.xml new file mode 100644 index 0000000..f7b2de6 --- /dev/null +++ b/server-deploy/assembly/assembly.xml @@ -0,0 +1,63 @@ + + + bin + + + tar.gz + + + true + + + + + src/main/scripts + bin + + *.sh + + 0755 + true + + + + + src/main/resources + conf + + application.yml + application-*.yml + logback-spring.xml + bootstrap.yml + *.properties + + 0644 + + + + + ${project.build.directory}/dependency + lib + + *.jar + + + ${project.artifactId}-${project.version}.jar + + 0644 + + + + + + + ${project.build.directory}/${project.artifactId}-${project.version}.jar + lib + ${project.artifactId}.jar + 0644 + + + + diff --git a/server-deploy/fund-cust/restart.sh b/server-deploy/fund-cust/restart.sh deleted file mode 100755 index 8b6d0af..0000000 --- a/server-deploy/fund-cust/restart.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# fund-cust 服务重启脚本 - -SCRIPT_DIR=$(dirname "$0") - -${SCRIPT_DIR}/stop.sh -sleep 3 -${SCRIPT_DIR}/start.sh diff --git a/server-deploy/fund-file/restart.sh b/server-deploy/fund-file/restart.sh deleted file mode 100755 index 57c8767..0000000 --- a/server-deploy/fund-file/restart.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# fund-file 服务重启脚本 - -SCRIPT_DIR=$(dirname "$0") - -${SCRIPT_DIR}/stop.sh -sleep 3 -${SCRIPT_DIR}/start.sh diff --git a/server-deploy/fund-gateway/restart.sh b/server-deploy/fund-gateway/restart.sh deleted file mode 100755 index 54d3384..0000000 --- a/server-deploy/fund-gateway/restart.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# fund-gateway 服务重启脚本 - -SCRIPT_DIR=$(dirname "$0") - -${SCRIPT_DIR}/stop.sh -sleep 3 -${SCRIPT_DIR}/start.sh diff --git a/server-deploy/fund-receipt/restart.sh b/server-deploy/fund-receipt/restart.sh deleted file mode 100755 index 35702b5..0000000 --- a/server-deploy/fund-receipt/restart.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# fund-receipt 服务重启脚本 - -SCRIPT_DIR=$(dirname "$0") - -${SCRIPT_DIR}/stop.sh -sleep 3 -${SCRIPT_DIR}/start.sh diff --git a/server-deploy/fund-report/restart.sh b/server-deploy/fund-report/restart.sh deleted file mode 100755 index 462ecf0..0000000 --- a/server-deploy/fund-report/restart.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# fund-report 服务重启脚本 - -SCRIPT_DIR=$(dirname "$0") - -${SCRIPT_DIR}/stop.sh -sleep 3 -${SCRIPT_DIR}/start.sh diff --git a/server-deploy/restart-all.sh b/server-deploy/scripts/restart-all.sh old mode 100755 new mode 100644 similarity index 100% rename from server-deploy/restart-all.sh rename to server-deploy/scripts/restart-all.sh diff --git a/server-deploy/scripts/restart.sh b/server-deploy/scripts/restart.sh new file mode 100644 index 0000000..57148fb --- /dev/null +++ b/server-deploy/scripts/restart.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# 服务重启脚本 +# 用法: ./restart.sh [服务名称] + +SCRIPT_DIR=$(dirname "$(readlink -f "$0")") + +${SCRIPT_DIR}/stop.sh +sleep 3 +${SCRIPT_DIR}/start.sh diff --git a/server-deploy/start-all.sh b/server-deploy/scripts/start-all.sh old mode 100755 new mode 100644 similarity index 79% rename from server-deploy/start-all.sh rename to server-deploy/scripts/start-all.sh index d754f07..f99e23f --- a/server-deploy/start-all.sh +++ b/server-deploy/scripts/start-all.sh @@ -21,13 +21,13 @@ echo " Starting all services..." echo "==========================================" for service in "${SERVICES[@]}"; do - if [ -f "${DEPLOY_HOME}/${service}/start.sh" ]; then + if [ -f "${DEPLOY_HOME}/${service}/bin/start.sh" ]; then echo "" echo "Starting ${service}..." - ${DEPLOY_HOME}/${service}/start.sh + ${DEPLOY_HOME}/${service}/bin/start.sh sleep 5 else - echo "Warning: ${service}/start.sh not found, skipping..." + echo "Warning: ${service}/bin/start.sh not found, skipping..." fi done diff --git a/server-deploy/scripts/start.sh b/server-deploy/scripts/start.sh new file mode 100644 index 0000000..e5cf7c2 --- /dev/null +++ b/server-deploy/scripts/start.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# 服务启动脚本 +# 用法: ./start.sh [服务名称] + +# 获取服务名称(从脚本所在目录推断) +SCRIPT_DIR=$(dirname "$(readlink -f "$0")") +APP_HOME=$(dirname "$SCRIPT_DIR") +APP_NAME=$(basename "$APP_HOME") + +LOG_HOME="/datacfs/applogs/${APP_NAME}" +JAR_FILE="${APP_HOME}/lib/${APP_NAME}.jar" +PID_FILE="${APP_HOME}/${APP_NAME}.pid" + +# JVM参数 +JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200" + +# 日志参数 +LOG_OPTS="-Dlogging.file.path=${LOG_HOME} -DAPP_NAME=${APP_NAME}" + +# 配置文件路径 +CONFIG_OPTS="--spring.config.location=${APP_HOME}/conf/application.yml" + +# 检查是否已运行 +if [ -f "$PID_FILE" ]; then + PID=$(cat $PID_FILE) + if ps -p $PID > /dev/null 2>&1; then + echo "${APP_NAME} is already running (PID: $PID)" + exit 1 + fi +fi + +# 创建日志目录 +mkdir -p ${LOG_HOME} + +# 启动服务 +echo "Starting ${APP_NAME}..." +nohup java $JAVA_OPTS $LOG_OPTS -jar $JAR_FILE $CONFIG_OPTS > /dev/null 2>&1 & + +# 保存PID +echo $! > $PID_FILE +echo "${APP_NAME} started (PID: $(cat $PID_FILE))" diff --git a/server-deploy/status.sh b/server-deploy/scripts/status-all.sh old mode 100755 new mode 100644 similarity index 100% rename from server-deploy/status.sh rename to server-deploy/scripts/status-all.sh diff --git a/server-deploy/scripts/status.sh b/server-deploy/scripts/status.sh new file mode 100644 index 0000000..c64f4a2 --- /dev/null +++ b/server-deploy/scripts/status.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# 查看服务状态 +# 用法: ./status.sh [服务名称] + +# 获取服务名称(从脚本所在目录推断) +SCRIPT_DIR=$(dirname "$(readlink -f "$0")") +APP_HOME=$(dirname "$SCRIPT_DIR") +APP_NAME=$(basename "$APP_HOME}") + +PID_FILE="${APP_HOME}/${APP_NAME}.pid" + +echo "==========================================" +echo " Service: ${APP_NAME}" +echo "==========================================" + +if [ -f "$PID_FILE" ]; then + PID=$(cat $PID_FILE) + if ps -p $PID > /dev/null 2>&1; then + echo "Status: \033[32mRUNNING\033[0m" + echo "PID: ${PID}" + + # 显示进程信息 + ps -p $PID -o pid,ppid,%cpu,%mem,etime,cmd --no-headers 2>/dev/null + else + echo "Status: \033[31mSTOPPED\033[0m (stale PID file)" + rm -f $PID_FILE + fi +else + echo "Status: \033[31mSTOPPED\033[0m" +fi + +echo "==========================================" diff --git a/server-deploy/stop-all.sh b/server-deploy/scripts/stop-all.sh old mode 100755 new mode 100644 similarity index 79% rename from server-deploy/stop-all.sh rename to server-deploy/scripts/stop-all.sh index 715869a..9b8a62b --- a/server-deploy/stop-all.sh +++ b/server-deploy/scripts/stop-all.sh @@ -21,13 +21,13 @@ echo " Stopping all services..." echo "==========================================" for service in "${SERVICES[@]}"; do - if [ -f "${DEPLOY_HOME}/${service}/stop.sh" ]; then + if [ -f "${DEPLOY_HOME}/${service}/bin/stop.sh" ]; then echo "" echo "Stopping ${service}..." - ${DEPLOY_HOME}/${service}/stop.sh + ${DEPLOY_HOME}/${service}/bin/stop.sh sleep 2 else - echo "Warning: ${service}/stop.sh not found, skipping..." + echo "Warning: ${service}/bin/stop.sh not found, skipping..." fi done diff --git a/server-deploy/fund-gateway/stop.sh b/server-deploy/scripts/stop.sh old mode 100755 new mode 100644 similarity index 74% rename from server-deploy/fund-gateway/stop.sh rename to server-deploy/scripts/stop.sh index ae6fb8d..c7327c6 --- a/server-deploy/fund-gateway/stop.sh +++ b/server-deploy/scripts/stop.sh @@ -1,8 +1,12 @@ #!/bin/bash -# fund-gateway 服务停止脚本 +# 服务停止脚本 +# 用法: ./stop.sh [服务名称] + +# 获取服务名称(从脚本所在目录推断) +SCRIPT_DIR=$(dirname "$(readlink -f "$0")") +APP_HOME=$(dirname "$SCRIPT_DIR") +APP_NAME=$(basename "$APP_HOME") -APP_NAME="fund-gateway" -APP_HOME="/opt/fundplatform/deploy/${APP_NAME}" PID_FILE="${APP_HOME}/${APP_NAME}.pid" # 检查是否运行