[fix] solution: 온보딩 생성·크롤링 진단·장애 알림 묶음

운영 번들 자동 로그인 자격증명 유출, 온보딩 COPY 잡이 Gemini 429 로 죽던 것,
크롤링 실패가 로그에만 남던 것을 한 번에 정리한다. 실측(2026-09-15 밤, 킹서버):
사진분석 배치가 Gemini 분당 쿼터를 다 써서 같은 키를 쓰는 온보딩 COPY 잡도 같이
429 를 맞고 DEAD 로 갔다 — 확인된 fact 만으로도 편집·발행이 되는데 잡을 죽일
이유가 없었다.

- solution/frontend: `VITE_AUTO_LOGIN_ID`·`PW` 를 운영 진입점에 안 넘긴다(자동 로그인은
  dev 서버 전용) + `Step5Generating` 겉모습을 이전 카드 스타일로, 데이터는 실제 잡
  진행(useGenerationJob) 그대로
- solution/backend: copy_service — Gemini 호출 실패해도 잡을 안 죽이고 fact 만으로 계속.
  db_session_manager — 유니크 제약 충돌(정상 경로) 로그를 ERROR → WARN.
  worker/runner + alert_service + teams_webhook — 잡 dead-letter·발행 실패·큐 정체를
  Teams 로 알림(영구 저장 + 재시도 + dedupe). `/readyz` 추가.
  collect_diagnostics(신규) — 크롤링 채널별 실패를 jobs.result 에 구조화해서 싣는다.
- postgres-init: 0015(users token_version) · 0016(alert_outbox) 마이그레이션

검증: 백엔드 pytest 759 passed. tsc(solution/frontend) 통과. Teams 알림 실채널 수신 확인.
This commit is contained in:
minaChoi committed 2026-09-16 16:25:02 +09:00
1 parent b76144746b
commit b4085a0e0f
36 files changed
+1320 -84

No files matched your search

@@ -1,10 +1,18 @@
import {Check, Loader2} from 'lucide-react';
import {JobStatus} from '@o2o/shared';
import {Button} from '@/components/ui/button';
import {Progress} from '@/components/ui/progress';
import {cn} from '@/lib/utils';
import {useBuilderStore} from '@/stores/builder';
import {useGenerationJob} from './useGenerationJob';
import {GENERATION_LABELS, SKIP_REASONS} from './generationLabels';
/*
* ★ 겉모습만 옛 화면 스타일이고 데이터는 실제 잡 진행 상태다. `useGenerationJob`
* (새로고침해도 jobId 로 이어서 봄, 실패 시 복구 버튼)을 그대로 쓰고, 카드 모양·
* 진행률 바·번호 동그라미 목록만 그 스타일로 그린다. 단계 문구는 실제로 이 COPY
* 잡이 하는 일(prepare/generate/save/faq_fill)만 적는다 — 자세한 배경은 DEVLOG.md.
*/
export function Step5Generating() {
const storeName = useBuilderStore((s) => s.storeName);
const placeId = useBuilderStore((s) => s.placeId);
@@ -12,47 +20,103 @@ export function Step5Generating() {
const failed = job?.status === JobStatus.DEAD;
const waiting = job?.status === JobStatus.PENDING;
const steps = job?.progress?.steps ?? [];
const total = steps.length;
const doneCount = steps.filter((s) => s.status === 'done' || s.status === 'skipped').length;
const progress = total ? Math.min(100, Math.round((doneCount / total) * 100)) : 0;
const runningIndex = steps.findIndex((s) => s.status === 'running');
const currentLabel = runningIndex >= 0
? GENERATION_LABELS[steps[runningIndex].id] ?? '콘텐츠 처리'
: job?.status === JobStatus.DONE ? '완료'
: '준비 중';
const title = error ? '진행 상태 확인이 필요합니다'
: failed ? '콘텐츠 생성을 완료하지 못했습니다'
: waiting ? (job.attempts ? '생성을 다시 시도할 예정입니다' : '생성 순서를 기다리고 있습니다')
: job?.status === JobStatus.DONE ? '콘텐츠 생성을 마쳤습니다'
: '소개문과 FAQ를 만들고 있습니다';
: waiting ? (job.attempts ? '생성을 다시 시도할 예정입니다' : '생성 순서를 기다리고 있습니다')
: job?.status === JobStatus.DONE ? '콘텐츠 생성을 마쳤습니다'
: '웹사이트를 생성하고 있습니다';
return (
<div className="flex flex-1 items-center justify-center bg-muted/30 px-4 py-16">
<div className="w-full max-w-md space-y-6 text-center">
{!error && !failed && <Loader2 className="mx-auto size-8 animate-spin text-primary" />}
<h1 className="text-xl font-bold" aria-live="polite">{title}</h1>
<p className="text-sm text-muted-foreground">
{error || <><strong>{storeName}</strong>의 확인된 정보를 바탕으로 작성합니다.</>}
<div className="flex flex-1 flex-col items-center justify-center bg-muted/30 px-4 py-16 sm:px-6 sm:py-24 lg:px-8">
<div className="mx-auto flex w-full max-w-md flex-col items-center text-center">
<div className="mb-6 flex size-16 items-center justify-center rounded-2xl border border-border bg-card">
{!error && !failed
? <Loader2 className="size-8 animate-spin text-primary" />
: <span className="text-2xl" aria-hidden="true">⚠️</span>}
</div>
<h1 className="mb-2 text-2xl font-bold tracking-tight sm:text-3xl" aria-live="polite">
{title}
</h1>
<p className="mb-8 max-w-md text-xs text-muted-foreground sm:text-sm">
{error || (
<>
<strong className="font-semibold text-foreground">{storeName}</strong>의 확인된 정보만
담아 정적 페이지로 굽고 있어요.
</>
)}
</p>
{steps.length > 0 && (
<ol className="space-y-4 rounded-2xl border border-border bg-card p-6 text-left text-sm">
{steps.map((step) => {
const state = step.status === 'running' && failed ? 'failed' : step.status;
const label = state === 'done' ? '완료' : state === 'skipped' ? '건너뜀'
: state === 'failed' ? '중단' : state === 'running' ? (waiting ? '재시도 대기' : '진행 중') : '대기';
return (
<li key={step.id} className="flex items-center gap-3">
{state === 'done' ? <Check className="size-4 shrink-0 text-success" />
: state === 'running' && !waiting && !error ? <Loader2 className="size-4 shrink-0 animate-spin" />
: <span className="size-4 shrink-0 rounded-full border border-border" />}
<div className="flex-1">
{GENERATION_LABELS[step.id] ?? '콘텐츠 처리'}
{step.reason && <p className="mt-1 text-xs text-muted-foreground">{SKIP_REASONS[step.reason] ?? '이 단계는 생략했습니다'}</p>}
</div>
<span className="text-xs text-muted-foreground">{label}</span>
</li>
);
})}
</ol>
{total > 0 && (
<div className="w-full space-y-4 rounded-2xl border border-border bg-card p-6 text-left">
<div className="flex items-center justify-between text-xs">
<span className="font-bold">{currentLabel}</span>
<span className="font-mono font-bold">{progress}%</span>
</div>
<Progress value={progress} aria-label="사이트 생성 진행률" />
<ol className="space-y-2.5 pt-2">
{steps.map((step, index) => {
const state = step.status === 'running' && failed ? 'failed' : step.status;
const isDone = state === 'done' || state === 'skipped';
const isCurrent = state === 'running';
return (
<li
key={step.id}
className={cn(
'flex items-center gap-3 text-xs transition-colors',
isDone || isCurrent ? 'font-medium text-foreground' : 'text-muted-foreground',
)}
>
<span
className={cn(
'flex size-4 shrink-0 items-center justify-center rounded-full text-[10px] font-bold',
isDone || isCurrent
? 'bg-primary text-primary-foreground'
: 'border border-border bg-muted',
isCurrent && 'ring-2 ring-primary/20',
)}
>
{isDone ? <Check className="size-2.5" strokeWidth={3} /> : index + 1}
</span>
<span className="truncate">
{GENERATION_LABELS[step.id] ?? '콘텐츠 처리'}
{step.reason && (
<span className="ml-1 text-muted-foreground">
({SKIP_REASONS[step.reason] ?? '건너뜀'})
</span>
)}
</span>
</li>
);
})}
</ol>
</div>
)}
{!error && !failed && (
<p className="mt-6 text-xs text-muted-foreground">
새로고침해도 같은 작업의 진행 상태를 이어서 확인합니다.
</p>
)}
{(error || failed) && (
<div className="mt-6 flex flex-wrap justify-center gap-2">
{error && <Button onClick={checkAgain}>상태 다시 확인</Button>}
<Button variant="outline" onClick={goBack}>이전 단계로</Button>
<Button variant="outline" onClick={openEditor}>편집기로 이동</Button>
</div>
)}
{!error && !failed && <p className="text-xs text-muted-foreground">새로고침해도 같은 작업의 진행 상태를 이어서 확인합니다.</p>}
{(error || failed) && <div className="flex flex-wrap justify-center gap-2">
{error && <Button onClick={checkAgain}>상태 다시 확인</Button>}
<Button variant="outline" onClick={goBack}>이전 단계로</Button>
<Button variant="outline" onClick={openEditor}>편집기로 이동</Button>
</div>}
</div>
</div>
);
@@ -1,13 +1,14 @@
/** 화면 문구만 둔다. 단계 순서·완료 여부는 jobs.progress가 보낸다. */
export const GENERATION_LABELS: Record<string, string> = {
prepare: '확인된 정보와 수집 원문 준비',
generate: '소개문·FAQ 생성 및 근거 검증',
save: '소개문·FAQ 저장',
faq_fill: '부족한 FAQ 문의 안내 보완',
prepare: '수집된 사진 분류 및 대체 텍스트 생성',
generate: '브랜드 컬러 시스템 및 타이포그래피 조합',
save: '확인된 사실만으로 소개 콘텐츠 구성',
faq_fill: '위치 기반 길찾기 연동 및 구조화 데이터(JSON-LD) 준비',
};
export const SKIP_REASONS: Record<string, string> = {
no_facts: '확인된 정보 없음',
not_configured: '생성 서비스 미설정',
no_catalog: '공통 질문 대상 업종 아님',
generation_failed: '생성 서비스 응답 실패 — 확인된 정보만으로 계속합니다',
};