발행이 SiteOntology 를 부르는데 서버는 따로 띄워야 했다. 실측(2026-09-14): 서버가 없으면 `[seo] SiteOntology 실패 — 키워드 없이 발행: ConnectError` 로 빌드는 성공하고 메타만 빈다 — 화면으로는 안 보이는 종류다. 한 벌로 묶어 "코드는 올라갔는데 서버가 없는" 상태를 없앤다. - ontology/: gitea.o2o.kr/Web4ai/o2o-site-ontology 를 이 레포로 편입(그 원격은 그대로 남는다) - ontology/Dockerfile(신규): 베이스는 node:22-slim. alpine 은 임베딩 런타임(onnxruntime)이 musl 바이너리를 안 줘서 적재가 ERR_DLOPEN_FAILED 로 죽는다 — 빌드는 성공하고 실행에서만 터진다 - docker-compose.yml: ontology · ontology-postgres(pgvector) · ontology-redis 추가. 자체 DB 를 쓰는 이유는 pgvector 확장 때문이다 — web4ai_db 를 남의 서비스 확장에 묶지 않는다 - 임베딩 모델(120MB)은 이미지에 굽지 않고 볼륨(ontology-model)에 남긴다 - 컨테이너끼리는 `http://ontology:3100` 으로 만난다. `.env` 의 127.0.0.1 은 컨테이너 자기 자신이라 안 닿는다 검증: 3개 기동 · 백엔드 컨테이너에서 ontology:3100/demo HTTP 200 · 마이그레이션·시드 완료 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
|
|
import { GenerationService } from '../generation/generation.service';
|
|
import { GenerationQueue } from '../generation/generation.queue';
|
|
import { MerchantsService, UpsertMerchantDto } from './merchants.service';
|
|
|
|
@Controller('v1/merchants')
|
|
export class MerchantsController {
|
|
constructor(
|
|
private readonly merchants: MerchantsService,
|
|
private readonly generation: GenerationService,
|
|
private readonly queue: GenerationQueue,
|
|
) {}
|
|
|
|
@Get()
|
|
list() {
|
|
return this.merchants.list();
|
|
}
|
|
|
|
@Get(':id')
|
|
get(@Param('id') id: string) {
|
|
return this.merchants.findWithTaxonomy(id);
|
|
}
|
|
|
|
/** o2o-site-AEO 사이트 발행 웹훅: 업체 등록 + 키워드 생성 예약 */
|
|
@Post('publish')
|
|
async publish(@Body() dto: UpsertMerchantDto & { generate?: boolean; sync?: boolean }) {
|
|
const merchant = await this.merchants.upsert(dto);
|
|
if (dto.generate === false) return { merchant, generation: 'skipped' };
|
|
|
|
if (dto.sync) {
|
|
const stats = await this.generation.runForMerchant(merchant.id, 'published');
|
|
return { merchant, generation: stats };
|
|
}
|
|
const jobId = await this.queue.enqueue(merchant.id, 'published');
|
|
return { merchant, generation: { queued: true, jobId } };
|
|
}
|
|
|
|
/** 수동 재생성 */
|
|
@Post(':id/generate')
|
|
async generate(
|
|
@Param('id') id: string,
|
|
@Query('sync') sync?: string,
|
|
@Query('count') count?: string,
|
|
) {
|
|
const target = count ? Math.min(Math.max(1, Number(count)), 500) : undefined;
|
|
if (sync === 'true' || sync === '1') {
|
|
return this.generation.runForMerchant(id, 'manual', target);
|
|
}
|
|
const m = await this.merchants.findWithTaxonomy(id);
|
|
const jobId = await this.queue.enqueue(m.id, 'manual');
|
|
return { queued: true, jobId };
|
|
}
|
|
}
|