J4025 Celeron 2C/2.0GHz에서 oversaturation을 일으키던 5개 패턴 해소. 1) 09:00 cron 스태거링 — agent-office insta_trends 09:00 / lotto 09:05 / youtube 09:10, realestate-lab collect 09:15. 동시 실행 4개가 직렬 분산되어 1분 단위로 분산됨. 2) lotto Monte Carlo 08:05 → 08:30 — stock 08:00 cron과 25분 분리. 3) insta-lab card_renderer.render_slate를 asyncio.Semaphore(1)로 감쌈. 동시 슬레이트 렌더 요청이 와도 Chromium 인스턴스 1개만 직렬 launch. 4) docker-compose healthcheck interval 30s → 60s (9 백엔드 + frontend 총 10개). 30초마다 동시 healthcheck로 인한 CPU 잡음 절반으로. 5) 9개 백엔드 Dockerfile CMD에 --workers 1 명시. 기본값 의존 제거. CHECK_POINT.md 갱신 — 즉시 5건 체크 + 변경 이력 한 줄. 적용 효과 검증: NAS 재기동 후 `docker stats` 비교. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
80 lines
2.5 KiB
Python
80 lines
2.5 KiB
Python
import asyncio
|
|
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
|
|
|
from .agents import AGENT_REGISTRY
|
|
|
|
scheduler = AsyncIOScheduler(timezone="Asia/Seoul")
|
|
|
|
async def _run_stock_schedule():
|
|
agent = AGENT_REGISTRY.get("stock")
|
|
if agent:
|
|
await agent.on_schedule()
|
|
|
|
async def _run_stock_screener():
|
|
agent = AGENT_REGISTRY.get("stock")
|
|
if agent:
|
|
await agent.on_screener_schedule()
|
|
|
|
async def _run_stock_ai_news():
|
|
agent = AGENT_REGISTRY.get("stock")
|
|
if agent:
|
|
await agent.on_ai_news_schedule()
|
|
|
|
async def _run_insta_schedule():
|
|
agent = AGENT_REGISTRY.get("insta")
|
|
if agent:
|
|
await agent.on_schedule()
|
|
|
|
|
|
async def _run_insta_trends_collect():
|
|
agent = AGENT_REGISTRY.get("insta")
|
|
if agent:
|
|
await agent.on_command("collect_trends", {})
|
|
|
|
async def _run_lotto_schedule():
|
|
agent = AGENT_REGISTRY.get("lotto")
|
|
if agent:
|
|
await agent.on_schedule()
|
|
|
|
async def _run_youtube_research():
|
|
agent = AGENT_REGISTRY.get("youtube")
|
|
if agent:
|
|
await agent.on_schedule()
|
|
|
|
async def _send_youtube_weekly_report():
|
|
agent = AGENT_REGISTRY.get("youtube")
|
|
if agent:
|
|
await agent.send_weekly_report()
|
|
|
|
async def _poll_pipelines():
|
|
agent = AGENT_REGISTRY.get("youtube_publisher")
|
|
if agent:
|
|
await agent.poll_state_changes()
|
|
|
|
def init_scheduler():
|
|
scheduler.add_job(_run_stock_schedule, "cron", hour=7, minute=30, id="stock_news")
|
|
scheduler.add_job(
|
|
_run_stock_screener,
|
|
"cron",
|
|
day_of_week="mon-fri",
|
|
hour=16,
|
|
minute=30,
|
|
id="stock_screener",
|
|
)
|
|
scheduler.add_job(
|
|
_run_stock_ai_news,
|
|
"cron",
|
|
day_of_week="mon-fri",
|
|
hour=8,
|
|
minute=0,
|
|
id="stock_ai_news_sentiment",
|
|
)
|
|
scheduler.add_job(_run_insta_schedule, "cron", hour=9, minute=30, id="insta_pipeline")
|
|
# 09:00 cron 스태거링 — Celeron 2C/2.0GHz에서 동시 실행 시 CPU 폭주 (CHECK_POINT FU-A)
|
|
scheduler.add_job(_run_insta_trends_collect, "cron", hour=9, minute=0, id="insta_trends_collect")
|
|
scheduler.add_job(_run_lotto_schedule, "cron", day_of_week="mon", hour=9, minute=5, id="lotto_curate")
|
|
scheduler.add_job(_run_youtube_research, "cron", hour=9, minute=10, id="youtube_research")
|
|
scheduler.add_job(_send_youtube_weekly_report, "cron", day_of_week="mon", hour=8, minute=0, id="youtube_weekly_report")
|
|
scheduler.add_job(_poll_pipelines, "interval", seconds=30, id="pipeline_poll")
|
|
scheduler.start()
|