feat(lps): 오픈마켓 폴백 기본 비활성(LPS_FALLBACKS 토글) — 협의 결정 B안 적용
2026-07-10 협의: 검색은 네이버+쿠팡만. G마켓·옥션·11번가 폴백은 최종 최저가 기여 0회에 검색당 최대 15s·프록시 비용 ~87%를 차지해 로직에서 제외. 주석처리 대신 env 토글로 코드·테스트는 살려둔다(부패 방지·env 한 줄 재가동). - worker_main: LPS_FALLBACKS(기본 빈값=OFF)로만 폴백 어댑터 생성, 잘못된 값 경고, 기동 로그에 폴백 상태 표기. 핸들러는 빈 폴백을 원래 정상 처리라 로직 변경 없음 - run_local_worker.sh: 폴백 여부 대화형 질문 추가(기본 비활성) - compose: LPS_FALLBACKS 주석 env(재가동용) - decision-openmarket-crawler.md: 결정(B)·근거·재가동 절차(라이브 스모크 선행) 확정 기록 - README·architecture·operations: 기본 비활성 반영 검증: 전체 테스트 106 passed(폴백 로직 테스트는 fake 주입이라 계속 유효), 워커 실기동 로그 '오픈마켓 폴백: OFF' 확인 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
89fe2c9805
commit
5e485e9b6e
7 files changed
+50
-18
No files matched your search
+26
-7
@@ -31,6 +31,21 @@ from worker.runner import Worker, run_reaper
|
||||
|
||||
LOG.SetPrefix(f"{web_server_config.server_name}-worker")
|
||||
|
||||
# 오픈마켓 폴백(G마켓·옥션·11번가)은 **기본 비활성** — 2026-07-10 협의 결정.
|
||||
# 실측상 크롤 몰이 최종 최저가를 바꾼 적이 없고(0회), 검색당 최대 15s + 프록시 대역폭의
|
||||
# 대부분을 차지해 로직에서 제외했다(코드·테스트는 유지, 핸들러는 빈 폴백을 정상 처리).
|
||||
# 재가동: LPS_FALLBACKS=gmarket,auction,st11 (일부만도 가능) — 켜기 전 라이브 스모크로
|
||||
# 셀렉터 드리프트 점검. 배경은 docs/decision-openmarket-crawler.md.
|
||||
_FALLBACK_SOURCES = ("gmarket", "auction", "st11")
|
||||
|
||||
|
||||
def _enabled_fallbacks() -> list[str]:
|
||||
names = [s.strip() for s in os.environ.get("LPS_FALLBACKS", "").split(",") if s.strip()]
|
||||
unknown = [n for n in names if n not in _FALLBACK_SOURCES]
|
||||
if unknown:
|
||||
LOG.w(f"LPS_FALLBACKS 무시된 값: {unknown} (가능: {list(_FALLBACK_SOURCES)})")
|
||||
return [n for n in names if n in _FALLBACK_SOURCES]
|
||||
|
||||
|
||||
def _build_worker(i: int, concurrency: int, has_openai: bool, neg_cache, history):
|
||||
"""워커 1개의 자립 세트(브라우저 어댑터·AI·핸들러)를 만든다.
|
||||
@@ -52,12 +67,14 @@ def _build_worker(i: int, concurrency: int, has_openai: bool, neg_cache, history
|
||||
"coupang": CoupangAdapter(headless=False, user_data_dir=_pf("coupang"), proxy=proxy, on_detect=bot_log.record),
|
||||
"naver": NaverAdapter(), # httpx 직접(프록시 미경유) — 워커별 인스턴스(last_bytes 경합 회피)
|
||||
}
|
||||
# 폴백은 데드라인이 상한이라 봇감지 재시도(챌린지 대기 2배)를 끈다(max_block_retries=0) — 빠르게 포기·스킵.
|
||||
fallback_adapters = {
|
||||
"gmarket": EsmAdapter("gmarket", headless=False, user_data_dir=_pf("gmarket"), proxy=proxy, on_detect=bot_log.record, max_block_retries=0),
|
||||
"auction": EsmAdapter("auction", headless=False, user_data_dir=_pf("auction"), proxy=proxy, on_detect=bot_log.record, max_block_retries=0),
|
||||
"st11": ElevenStAdapter(headless=False, user_data_dir=_pf("st11"), proxy=proxy, on_detect=bot_log.record, max_block_retries=0),
|
||||
}
|
||||
# 폴백은 기본 비활성(LPS_FALLBACKS 로 켬 — 상단 주석 참고). 켤 땐 데드라인이 상한이라
|
||||
# 봇감지 재시도(챌린지 대기 2배)를 끈다(max_block_retries=0) — 빠르게 포기·스킵.
|
||||
fallback_adapters = {}
|
||||
for name in _enabled_fallbacks():
|
||||
if name == "st11":
|
||||
fallback_adapters[name] = ElevenStAdapter(headless=False, user_data_dir=_pf("st11"), proxy=proxy, on_detect=bot_log.record, max_block_retries=0)
|
||||
else:
|
||||
fallback_adapters[name] = EsmAdapter(name, headless=False, user_data_dir=_pf(name), proxy=proxy, on_detect=bot_log.record, max_block_retries=0)
|
||||
# AI 도 워커별 인스턴스 — 공유 상태(last_usage) 경합 원천 제거
|
||||
judge = SimilarityJudge() if has_openai else None
|
||||
keyword_gen = KeywordGenerator() if has_openai else None
|
||||
@@ -164,7 +181,9 @@ async def main(concurrency: int = 1):
|
||||
egress_ip, egress_port = await probe.healthcheck()
|
||||
LOG.i(f"DECODO 프리플라이트 OK — egress IP {egress_ip} (port {egress_port})") if egress_ip \
|
||||
else LOG.w("DECODO 프리플라이트 실패 — 살아있는 포트를 못 찾음(런타임 회전으로 재시도)")
|
||||
LOG.i(f"AI(판정+검색어생성): {'ON' if has_openai else 'OFF(키 없음)'} · 오픈마켓 폴백: gmarket, auction, st11")
|
||||
fb = _enabled_fallbacks()
|
||||
LOG.i(f"AI(판정+검색어생성): {'ON' if has_openai else 'OFF(키 없음)'} · "
|
||||
f"오픈마켓 폴백: {', '.join(fb) if fb else 'OFF(기본 — LPS_FALLBACKS 로 활성화)'}")
|
||||
|
||||
stop = asyncio.Event()
|
||||
listeners: list[JobListener] = []
|
||||
|
||||
Reference in new issue
Block a user