This repository has been archived on 2026-10-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
NeteaseUrl/entrypoint.sh
T
snowy-yang 52ed8b54fb feat(server): 生产服务器切换 uvicorn(FastAPI + Flask 兜底)
- web/main.py:uvicorn 入口,默认开启 Flask 兜底(未迁移路由回落遗留应用);
  HOST/PORT/LOG_LEVEL 环境变量可配;proxy_headers 按 XFF 取真实 IP(仅信回环);
  server_header=False 抹服务器指纹
- entrypoint.sh:默认 exec web/main.py;WEB_STACK=flask 可应急回退旧入口
- Dockerfile:安装 requirements-fastapi.txt(目标栈)+ requirements.txt(Flask 兜底)

验证(单进程双框架实跑):/health、/(Flask 兜底)与 /api/v1/site/stats(FastAPI)
均 200;Server 头为 NeteaseUrl;ruff/pyright 干净。
2026-09-26 00:35:02 +08:00

19 lines
969 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
# F59:exec 让 python 成为 PID 1 直接接收 SIGTERM,容器停止不再经 shell 转发而超时
# 第 93 条(P2-4):compose 挂载 ./user_cookie.txt 时若宿主不存在该文件,Docker 会
# 在启动前创建同名**目录**并挂载——容器内 touch 只对无卷 docker run 有效。
# 第 97 条(P3):检测到同名目录直接报错退出(fail-fast),不再静默带病运行
for f in user_cookie.txt cookie.txt; do
if [ -d "/app/$f" ]; then
echo "FATAL: /app/$f 是目录(宿主机缺文件时 Docker 挂载会建同名目录)。请在宿主机先 touch 该文件再启动。" >&2
exit 1
fi
[ -f "/app/$f" ] || touch "/app/$f"
done
# 生产服务器改为 uvicorn(FastAPI + Flask 兜底,见 web/main.py)
# WEB_STACK=flask 可回退到旧入口 main.py(waitress/Werkzeug)以应急
if [ "${WEB_STACK:-fastapi}" = "flask" ]; then
exec python3 main.py
fi
exec python3 web/main.py