图片生成改为每张一条并行请求,根治多图生成超时 500

根因:多图生成走一条 HTTP 串行出 N 张,4 张累计 >120s 被 gunicorn 强杀 worker → 500
(日志实锤 SystemExit on ARK response.begin)。采纳用户建议拆成「每张一条请求」:

- App.tsx generateImages: 拆成 N 条并行单张请求(Promise.allSettled),单张约 30s 不超时,
  并行后总耗时≈单张(比串行快 N 倍),任一张失败只丢那张(各自独立扣费/回滚)
- Dockerfile: gunicorn --timeout 120→300,给慢 ARK 留余量(双保险)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
zyc
2026-06-15 15:38:08 +08:00
co-authored by Claude Opus 4.8
parent a8852345db
commit 9c3e4e5c8b
2 changed files with 18 additions and 2 deletions
+3 -1
View File
@@ -32,4 +32,6 @@ RUN chmod +x /usr/local/bin/docker-entrypoint.sh
EXPOSE 8000
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["gunicorn", "airshelf.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "3", "--timeout", "120"]
# timeout 300:前端已把多图生成拆成「每张一条请求」,单张约 30s;300s 给慢 ARK 留充足余量,
# 不再因一条请求串行出多张而超时(旧 120s 下生成 4 张必被 worker 强杀 → 500)。
CMD ["gunicorn", "airshelf.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "3", "--timeout", "300"]