[fix] solution/backend: Teams 는 장애만 — 수집·발행 시작·완료 알림 제거, 빌드 실패 중복 발송 정리
수집 1회에 3~4장, 발행 1회에 2장씩 와서 장애 알림이 묻혔다. 빌드·되돌리기 실패와 수집 예외는 기존 build_failed · job_dead 알림이 이미 보내고 있어 같은 사고가 두 번씩 갔다. - collect_service: 시작·완료 요약·예외 알림 제거 — 채널 크롤링 실패만 남긴다(채널별 결과는 잡 결과 channels 에 그대로) - vision_service: 실패가 있을 때만 - build_service · rollback_service: activity 알림 되돌림 — build_failed · recovery 가 그대로 담당 - docs/ALERTS.md: activity 행을 실제 발송 범위로 관련 테스트 17개 파일 297 passed · 2 failed(test_search_console_service — 변경 전에도 실패) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ca0bea77a7
commit
b75c56a0d6
5 files changed
+11
-124
No files matched your search
@@ -1,6 +1,5 @@
|
||||
"""정적 빌드 + 발행 — BUILD 잡이 하는 일."""
|
||||
import os
|
||||
import time
|
||||
import uuid
|
||||
|
||||
from sqlalchemy import select
|
||||
@@ -26,7 +25,6 @@ from crud.site_crud import SiteCRUD
|
||||
from crud.place_crud import PlaceCRUD
|
||||
from crud.post_crud import PostCRUD
|
||||
from services import (
|
||||
activity_feed,
|
||||
alert_service,
|
||||
azure_static,
|
||||
indexnow,
|
||||
@@ -120,45 +118,6 @@ async def _log(site_id, version_id, action: PublishAction, result: PublishResult
|
||||
|
||||
async def run_build(job: dict) -> dict:
|
||||
"""BUILD 잡 핸들러."""
|
||||
started = time.monotonic()
|
||||
try:
|
||||
result = await _run_build(job)
|
||||
except Exception as ex:
|
||||
await activity_feed.post(
|
||||
"❌ 빌드 실패",
|
||||
[f"place_id={job['payload'].get('place_id')}", f"{type(ex).__name__}: {ex}",
|
||||
f"{time.monotonic() - started:.0f}초"],
|
||||
)
|
||||
raise
|
||||
await post_build_summary(result, time.monotonic() - started)
|
||||
return result
|
||||
|
||||
|
||||
async def post_build_summary(result: dict, elapsed: float) -> None:
|
||||
version = f"v{result.get('version')}"
|
||||
mode = result.get("mode") or "빌드"
|
||||
lines = [f"{result.get('label') or result.get('place_id')} {version}"]
|
||||
if result.get("build_status") == "BUILT":
|
||||
title = f"✅ {mode} 완료"
|
||||
if result.get("url"):
|
||||
lines.append(result["url"])
|
||||
elif result.get("gate", {}).get("passed") is False:
|
||||
title = f"🚫 {mode} 반려(게이트)"
|
||||
lines.append(str(result.get("error") or ""))
|
||||
else:
|
||||
title = f"❌ {mode} 실패"
|
||||
lines.append(str(result.get("error") or ""))
|
||||
media = result.get("render_media")
|
||||
if media:
|
||||
lines.append(
|
||||
f"굽기 — 사진 {media.get('total', 0)}장: 새로 받음 {media.get('fetched', 0)} · "
|
||||
f"기존 {media.get('cached', 0)} · 실패 {media.get('failed', 0)}"
|
||||
)
|
||||
lines.append(f"{elapsed:.0f}초")
|
||||
await activity_feed.post(title, lines)
|
||||
|
||||
|
||||
async def _run_build(job: dict) -> dict:
|
||||
payload = job["payload"]
|
||||
place_id = payload["place_id"]
|
||||
owner_user_id = payload["owner_user_id"]
|
||||
@@ -173,7 +132,6 @@ async def _run_build(job: dict) -> dict:
|
||||
raise BuildAborted(f"사업장을 찾을 수 없다: {place_id}")
|
||||
|
||||
site = await ensure_site(place_id)
|
||||
mode = ("재발행" if site.published_at is not None else "첫 발행") if want_publish else "빌드만"
|
||||
|
||||
# 주변 정보(맛집·관광지·축제·코스)는 빌드 시점에 업장 좌표로 새로 받는다 — 발행본은 정적이라 이때 받은 값이 실린다.
|
||||
try:
|
||||
@@ -240,12 +198,7 @@ async def _run_build(job: dict) -> dict:
|
||||
raise BuildAborted(f"버전 생성 실패: {add_err.name}")
|
||||
|
||||
result = {"place_id": place_id, "site_id": str(site.site_id), "version": version_no,
|
||||
"site_version_id": str(version.site_version_id), "label": activity_feed.place_label(place),
|
||||
"mode": mode}
|
||||
await activity_feed.post(
|
||||
f"🏗 {mode} 시작",
|
||||
[f"{result['label']} v{version_no}", f"템플릿 {site.template_id or '기본'}"],
|
||||
)
|
||||
"site_version_id": str(version.site_version_id)}
|
||||
# 잡 결과에 남긴다 — "노래가 왜 없나" 를 잡 하나만 열어 보면 알 수 있어야 한다.
|
||||
if song_result is not None:
|
||||
result["song"] = song_result
|
||||
@@ -314,8 +267,6 @@ async def _run_build(job: dict) -> dict:
|
||||
# 발행하지 않는다.
|
||||
return await _fail(str(ex))
|
||||
|
||||
if report.get("media"):
|
||||
result["render_media"] = report["media"]
|
||||
mismatches = list(report.get("mismatches") or [])
|
||||
unique_count_raw = report.get("uniqueContentCount")
|
||||
unique_count = unique_count_raw or 0
|
||||
@@ -415,7 +366,6 @@ async def _run_build(job: dict) -> dict:
|
||||
if thumbnail_url:
|
||||
site.thumbnail_url = thumbnail_url
|
||||
result["published"] = True
|
||||
result["url"] = site_payload.publish_url(place, site)
|
||||
LOG.i(f"[build] place={place_id} v{version_no} 발행 완료 "
|
||||
f"(고유 콘텐츠 {unique_count}건 · {report.get('routes')} 페이지)")
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user