feat(daemon): instance-level enable flag (dev/prod 중복 폴링 방지)

dev와 prod가 같은 Oracle ATP 인스턴스(_low vs _medium tier만 다름)를 공유하는
환경에서 dev/prod 양쪽 DaemonScheduler가 같은 daemon_config row를 폴링하면
같은 시점에 동일 채널 스캔이 발생 → YouTube 봇 감지 위험 증가.

수정:
- application.yml: app.daemon.enabled (env DAEMON_ENABLED, 기본 true)
- DaemonScheduler.run() 첫 줄에서 인스턴스 플래그 검사 후 차단
- dev/backend/.env에 DAEMON_ENABLED=false 설정 (이 커밋엔 미포함, 로컬만)

운영(OKE)은 env 미설정 → 기본 true로 정상 동작.
dev(PM2)는 .env로 false → 스케줄러 자체가 동작 안 함.

Refs: #275 #321
This commit is contained in:
joungmin
2026-06-15 12:50:41 +09:00
parent 51dcacc728
commit d3cd1b5d5f
2 changed files with 13 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package com.tasteby.service;
import com.tasteby.domain.DaemonConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
@@ -22,6 +23,9 @@ public class DaemonScheduler {
private final PipelineService pipelineService;
private final CacheService cacheService;
@Value("${app.daemon.enabled:true}")
private boolean instanceEnabled;
public DaemonScheduler(DaemonConfigService daemonConfigService,
YouTubeService youTubeService,
PipelineService pipelineService,
@@ -34,6 +38,10 @@ public class DaemonScheduler {
@Scheduled(fixedDelay = 30_000) // Check every 30 seconds
public void run() {
// 인스턴스 차원 차단(dev/prod 동일 DB 공유 환경에서 dev 쪽 동시 폴링 방지).
// dev .env: DAEMON_ENABLED=false → 이 인스턴스는 스케줄러 동작 안 함.
// prod: 미설정 → 기본 true.
if (!instanceEnabled) return;
try {
var config = getConfig();
if (config == null) return;

View File

@@ -59,6 +59,11 @@ app:
cache:
ttl-seconds: 600
daemon:
# 인스턴스 차원 스케줄러 활성화. dev/prod가 같은 DB를 공유하므로
# dev .env에 DAEMON_ENABLED=false를 설정해 dev 폴링을 끄고 prod만 동작시킨다.
enabled: ${DAEMON_ENABLED:true}
mybatis:
mapper-locations: classpath:mybatis/mapper/*.xml
config-location: classpath:mybatis/mybatis-config.xml