Compare commits

...

17 Commits

Author SHA1 Message Date
孙小云 7cf507aaa1 xx 2026-01-09 19:15:45 +08:00
孙小云 02859b637e Merge branch 'main' of http://th.local.t-aaron.com:13000/THENG/a-cloud-all 2026-01-09 19:06:19 +08:00
孙小云 cf65e91a45 Merge branch 'main' of http://th.local.t-aaron.com:13000/THENG/a-cloud-all 2026-01-09 19:04:40 +08:00
孙小云 72d3ec8f65 Merge branch 'main' of http://th.local.t-aaron.com:13000/THENG/a-cloud-all 2026-01-09 19:03:07 +08:00
孙小云 e0c6bf1b75 Merge branch 'main' of http://th.local.t-aaron.com:13000/THENG/a-cloud-all 2026-01-09 19:02:00 +08:00
孙小云 35c3eb4908 Merge branch 'main' of http://th.local.t-aaron.com:13000/THENG/a-cloud-all 2026-01-09 19:00:41 +08:00
孙小云 04e8cf309d Merge branch 'main' of http://th.local.t-aaron.com:13000/THENG/a-cloud-all 2026-01-09 18:58:47 +08:00
孙小云 0a17a96363 Merge branch 'main' of http://th.local.t-aaron.com:13000/THENG/a-cloud-all 2026-01-09 18:57:19 +08:00
孙小云 dfc40b892e Merge branch 'main' of http://th.local.t-aaron.com:13000/THENG/a-cloud-all 2026-01-09 18:55:20 +08:00
孙小云 589159c025 修复:Node.js 项目在子模块目录执行构建命令 2026-01-09 18:47:56 +08:00
孙小云 05f0cf1dad Merge branch 'main' of http://th.local.t-aaron.com:13000/THENG/a-cloud-all 2026-01-09 18:44:31 +08:00
孙小云 8c036c003d Merge branch 'main' of http://th.local.t-aaron.com:13000/THENG/a-cloud-all 2026-01-09 18:41:54 +08:00
孙小云 77a75a5487 xx 2026-01-09 18:41:33 +08:00
孙小云 ddf030a178 添加基础设施服务启动等待时间
- MySQL 等待 30 秒初始化
- Redis 等待 10 秒
- Nacos 等待 20 秒(确保 MySQL 就绪)
- 解决 Nacos 无法连接 MySQL 的问题
2026-01-09 18:36:16 +08:00
孙小云 bae9bdd9a0 修复日志配置:配置根 logger 以显示所有部署过程日志 2026-01-09 18:30:09 +08:00
孙小云 c6dd75daeb 修复:在主仓库根目录执行构建命令 2026-01-09 18:23:44 +08:00
孙小云 1813a448e8 改进命令输出:显示完整的标准输出和错误输出 2026-01-09 18:22:11 +08:00
4 changed files with 58 additions and 18 deletions

View File

@ -217,11 +217,14 @@ infrastructure:
- cp sql/ry_20250523.sql docker/mysql/db/
- cp sql/ry_config_20250902.sql docker/mysql/db/
deployed_flag: .devops/.deployed_mysql
wait_time: 30 # MySQL 需要更长时间初始化
- name: ruoyi-redis
docker_service: ruoyi-redis
deployed_flag: .devops/.deployed_redis
wait_time: 10 # Redis 启动较快
- name: ruoyi-nacos
docker_service: ruoyi-nacos
deployed_flag: .devops/.deployed_nacos
wait_time: 20 # Nacos 需要等待 MySQL 就绪

View File

@ -54,15 +54,31 @@ class Deployer:
timeout=timeout
)
# 始终输出标准输出(如果有)
if result.stdout:
self.logger.debug(f"标准输出:\n{result.stdout}")
# 限制输出长度,避免日志过大
stdout_lines = result.stdout.strip().split('\n')
if len(stdout_lines) > 50:
self.logger.info(f"标准输出 (前30行):\n" + '\n'.join(stdout_lines[:30]))
self.logger.info(f"... (省略 {len(stdout_lines) - 50} 行)")
self.logger.info(f"标准输出 (后20行):\n" + '\n'.join(stdout_lines[-20:]))
else:
self.logger.info(f"标准输出:\n{result.stdout.strip()}")
if result.returncode != 0:
self.logger.error(f"命令执行失败 (退出码: {result.returncode})")
if result.stderr:
self.logger.error(f"错误输出:\n{result.stderr}")
# 限制错误输出长度
stderr_lines = result.stderr.strip().split('\n')
if len(stderr_lines) > 50:
self.logger.error(f"错误输出 (前30行):\n" + '\n'.join(stderr_lines[:30]))
self.logger.error(f"... (省略 {len(stderr_lines) - 50} 行)")
self.logger.error(f"错误输出 (后20行):\n" + '\n'.join(stderr_lines[-20:]))
else:
self.logger.error(f"错误输出:\n{result.stderr.strip()}")
return False
self.logger.info("命令执行成功")
return True
except subprocess.TimeoutExpired:
self.logger.error(f"命令执行超时 (超时时间: {timeout}秒)")
@ -136,14 +152,23 @@ class Deployer:
def build_project(self, repo_config):
"""构建项目"""
repo_path = self.runtime_path / 'a-cloud-all'
submodule_path = repo_path / repo_config['path']
self.logger.info(f"开始构建: {repo_config['name']}")
# 根据项目类型选择执行目录
if repo_config['type'] == 'nodejs':
# Node.js 项目在子模块目录执行
build_dir = repo_path / repo_config['path']
self.logger.info(f"Node.js 项目,在子模块目录执行构建")
else:
# Java 项目在主仓库根目录执行
build_dir = repo_path
self.logger.info(f"Java 项目,在主仓库根目录执行构建")
# 执行构建命令
for cmd in repo_config['build_commands']:
self.logger.info(f"执行构建命令: {cmd}")
if not self.run_command(cmd, cwd=submodule_path, timeout=1800):
if not self.run_command(cmd, cwd=build_dir, timeout=1800):
self.logger.error(f"构建失败: {cmd}")
return False
@ -335,6 +360,12 @@ class Deployer:
self.logger.error(f"部署失败: {name}")
return False
# 等待服务启动(特别是 MySQL 和 Redis
wait_time = infra.get('wait_time', 10)
self.logger.info(f"等待 {name} 启动完成 ({wait_time} 秒)...")
import time
time.sleep(wait_time)
# 创建部署标记
deployed_flag.parent.mkdir(parents=True, exist_ok=True)
deployed_flag.touch()

View File

@ -55,16 +55,22 @@ class GitMonitor:
# 文件处理器
file_handler = logging.FileHandler(log_file, encoding='utf-8')
file_handler.setFormatter(formatter)
file_handler.setLevel(log_level)
# 控制台处理器
console_handler = logging.StreamHandler()
console_handler.setFormatter(formatter)
console_handler.setLevel(log_level)
# 配置 logger
# 配置根 logger让所有子 logger 都能输出
root_logger = logging.getLogger()
root_logger.setLevel(log_level)
root_logger.addHandler(file_handler)
root_logger.addHandler(console_handler)
# 配置当前 logger
self.logger = logging.getLogger('GitMonitor')
self.logger.setLevel(log_level)
self.logger.addHandler(file_handler)
self.logger.addHandler(console_handler)
def get_remote_commit(self, repo_url, branch):
"""获取远程仓库的最新提交 hash"""

2
use.md
View File

@ -1,4 +1,4 @@
# RuoYi-Cloud 代码拉取说明
## RuoYi-Cloud 代码拉取说明
## 首次克隆代码
```bash