fix(orchestrator): spawn 子进程 PYTHONPATH + entrypoint 回根治孤儿
CI/CD / test (push) Successful in 8s
CI/CD / nas-deploy (push) Failing after 33s
CI/CD / nas-verify (push) Has been skipped

ProcessPoolExecutor(spawn)子进程不继承主进程 sys.path(insert 是内存修改),
import sanguo_orchestrator 失败->BrokenProcessPool->API 回测静默失败,POST 秒回
task_id 但轮询永远 404。spawn 继承 env 不继承 sys.path,故:
1. Dockerfile ENV PYTHONPATH=/app:/app/vnpy_v4.4.0(镜像层,bind mount 覆盖不了)
2. entrypoint.sh 回仓库根(git mv 自 docker/):promote --exclude /docker 致旧版
   entrypoint 在 NAS 成 git 外孤儿(340行,被 bind mount 覆盖镜像层);回根后全量
   rsync 自动推可复现(对齐 docs/deployment/nas-deploy-plan.md 预设修复)+export 兜底
3. 三 Dockerfile COPY 路径同步

反馈: 策略 session(根因诊断+探针验证)
This commit is contained in:
2026-08-01 21:33:20 +08:00
parent ca0ec016f9
commit 6d786fbf41
4 changed files with 9 additions and 3 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ ENV TZ=Asia/Shanghai \
DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=/app:/app/vnpy_v4.4.0 \
VNPY_LOG_LEVEL=INFO \
TA_LIBRARY_PATH=/usr/local/lib \
TA_INCLUDE_PATH=/usr/local/include
@@ -60,7 +61,7 @@ COPY sanguo_data/ /app/sanguo_data/
COPY sanguo_common/ /app/sanguo_common/
# 复制启动脚本
COPY docker/entrypoint.sh /app/
COPY entrypoint.sh /app/
RUN chmod +x /app/entrypoint.sh
# 暴露端口
+1 -1
View File
@@ -33,7 +33,7 @@ COPY vnpy_v4.4.0/vnpy/ /app/vnpy/
COPY run_web.py /app/
# 复制启动脚本
COPY docker/entrypoint.sh /app/
COPY entrypoint.sh /app/
RUN chmod +x /app/entrypoint.sh
# 暴露端口
+1 -1
View File
@@ -18,7 +18,7 @@ COPY vnpy_v4.4.0/vnpy/ ./vnpy/
COPY config/ ./config/
# 复制启动脚本
COPY docker/entrypoint.sh .
COPY entrypoint.sh .
RUN chmod +x entrypoint.sh
# 创建数据目录
+5
View File
@@ -63,6 +63,11 @@ check_env() {
export PYTHONUNBUFFERED="${PYTHONUNBUFFERED:-1}"
export PYTHONDONTWRITEBYTECODE="${PYTHONDONTWRITEBYTECODE:-1}"
# Python 路径(关键): ProcessPoolExecutor(spawn)子进程不继承主进程 sys.path(内存修改),
# 但继承环境变量。设 PYTHONPATH 让 spawn 子进程 import sanguo_*/vnpy 不 ModuleNotFoundError→BrokenProcessPool。
# 镜像 Dockerfile ENV 同设此值(优先),此行为旧镜像/无 ENV 时兜底。
export PYTHONPATH="${PYTHONPATH:-/app:/app/vnpy_v4.4.0}"
# VeighNa 配置
export VNPY_LOG_LEVEL="${VNPY_LOG_LEVEL:-INFO}"
export VNPY_LOG_FILE="${VNPY_LOG_FILE:-/app/logs/vnpy.log}"