feat: P2V 파이프라인 워커를 전용 프로세스로 분리

- P2V_WORKER_ENABLED 추가: false 면 웹 프로세스가 워커를 시작하지 않는다(API·목록은 그대로)
- app/p2v/worker/standalone.py: HTTP 없이 큐만 처리하는 단독 워커 진입점
- gunicorn 워커가 여럿일 때 같은 잡 중복 실행과 재시작 시 requeue 오작동을 막는다
This commit is contained in:
skkim committed 2026-10-15 13:58:22 +09:00
1 parent 744262633c
commit a92432867c
3 files changed
+65 -3

No files matched your search

+7 -3
View File
@@ -54,7 +54,9 @@ async def lifespan(app: FastAPI):
f"{type(e).__name__}: {e}"
)
if p2v_settings.P2V_ENABLED:
# 워커는 프로세스당 하나만 있어야 한다(같은 잡을 중복 집는다). gunicorn 워커가 여럿인
# 서버는 P2V_WORKER_ENABLED=false 로 이 경로를 끄고 standalone 프로세스를 따로 돌린다
if p2v_settings.P2V_ENABLED and p2v_settings.P2V_WORKER_ENABLED:
from app.p2v.worker import worker as p2v_worker
p2v_worker.start()
@@ -87,9 +89,11 @@ async def lifespan(app: FastAPI):
# P2V 워커 중단. 진행 중이던 잡은 다음 기동의 requeue_running 이 이어서 돌린다
if p2v_settings.P2V_ENABLED:
from app.p2v.utils import blob as p2v_blob
from app.p2v.worker import worker as p2v_worker
await p2v_worker.stop()
if p2v_settings.P2V_WORKER_ENABLED:
from app.p2v.worker import worker as p2v_worker
await p2v_worker.stop()
await p2v_blob.close_client()
# 공유 HTTP 클라이언트 종료