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:
@@ -1682,13 +1682,17 @@ async def hairline_grow_v2_final_v2(
|
||||
|
||||
@app.get("/api/v1/debug/hairline_log", include_in_schema=False)
|
||||
async def download_hairline_log(rid: Optional[str] = None, tail: int = 500):
|
||||
"""返回 /home/xsl/hair/log/hairline_grow.log 的内容。
|
||||
"""返回 <仓库根>/log/hairline_grow.log 的内容。
|
||||
|
||||
rid 非空时只返回该 request id 相关的行;tail 限制返回最后 N 行(默认 500)。
|
||||
供调试页"下载日志"按钮调用。
|
||||
"""
|
||||
from fastapi.responses import PlainTextResponse
|
||||
log_path = "/home/xsl/hair/log/hairline_grow.log"
|
||||
log_path = os.getenv(
|
||||
"HAIR_LOG_DIR",
|
||||
os.path.join(os.path.dirname(os.path.abspath(__file__)), "log"),
|
||||
)
|
||||
log_path = os.path.join(log_path, "hairline_grow.log")
|
||||
try:
|
||||
with open(log_path, encoding="utf-8") as fh:
|
||||
lines = fh.readlines()
|
||||
|
||||
Reference in New Issue
Block a user