fix: 日志目录去掉硬编码 /home/xsl,改为基于仓库根解析(支持 HAIR_LOG_DIR 覆盖)

worker 部署到 /home/ubuntu 等其他路径时,原硬编码 /home/xsl/hair/log
会导致 Permission denied。改为相对仓库根,兼容多机部署。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
xsl
2026-07-16 08:07:03 +08:00
co-authored by Cursor
parent 12f34c44f2
commit e8a2c5a8a1
2 changed files with 11 additions and 4 deletions
+5 -2
View File
@@ -47,8 +47,11 @@ from face_analysis.head_mask import (
_draw_baseline,
)
# 调试日志:写 /home/xsl/hair/log/hairline_grow.log,每个步骤详细记录
_LOG_DIR = "/home/xsl/hair/log"
# 调试日志:写 <仓库根>/log/hairline_grow.log,每个步骤详细记录(可用 HAIR_LOG_DIR 覆盖)
_LOG_DIR = os.getenv(
"HAIR_LOG_DIR",
os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "log"),
)
os.makedirs(_LOG_DIR, exist_ok=True)
logger = logging.getLogger("hairline_grow")
_log_fh = logging.FileHandler(os.path.join(_LOG_DIR, "hairline_grow.log"), encoding="utf-8")