修复 runtime 路径问题,使用绝对路径

This commit is contained in:
孙小云 2026-01-09 17:50:53 +08:00
parent 238d0276d8
commit 2e4d866634
1 changed files with 14 additions and 1 deletions

View File

@ -21,10 +21,23 @@ class Deployer:
"""初始化部署器"""
self.config = config
self.logger = logging.getLogger('Deployer')
self.runtime_path = Path(config['main_repository']['runtime_path'])
# 获取项目根目录(.devops 的父目录)
project_root = Path(__file__).parent.parent.resolve()
# 将 runtime_path 转换为绝对路径
runtime_path = config['main_repository']['runtime_path']
if not Path(runtime_path).is_absolute():
self.runtime_path = project_root / runtime_path
else:
self.runtime_path = Path(runtime_path)
self.main_repo_url = config['main_repository']['url']
self.main_repo_branch = config['main_repository']['branch']
self.logger.info(f"项目根目录: {project_root}")
self.logger.info(f"Runtime 目录: {self.runtime_path}")
def run_command(self, cmd, cwd=None, timeout=600):
"""执行命令"""
self.logger.info(f"执行命令: {cmd}")