Initial commit: Tasteby - YouTube restaurant map service
Backend (FastAPI + Oracle ADB), Frontend (Next.js), daemon worker. Features: channel/video/restaurant management, semantic search, Google OAuth, user reviews. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
0
backend/daemon/__init__.py
Normal file
0
backend/daemon/__init__.py
Normal file
37
backend/daemon/worker.py
Normal file
37
backend/daemon/worker.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""Daemon worker: periodic channel scan + video processing."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
from core.youtube import scan_all_channels
|
||||
from core.pipeline import process_pending
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_once() -> None:
|
||||
"""Single daemon cycle: scan channels then process pending videos."""
|
||||
logger.info("=== Daemon cycle start ===")
|
||||
try:
|
||||
new_count = scan_all_channels()
|
||||
logger.info("Scan complete: %d new videos", new_count)
|
||||
except Exception as e:
|
||||
logger.error("Channel scan failed: %s", e)
|
||||
|
||||
try:
|
||||
rest_count = process_pending(limit=10)
|
||||
logger.info("Processing complete: %d restaurants extracted", rest_count)
|
||||
except Exception as e:
|
||||
logger.error("Video processing failed: %s", e)
|
||||
|
||||
logger.info("=== Daemon cycle end ===")
|
||||
|
||||
|
||||
def run_loop(interval: int = 3600) -> None:
|
||||
"""Run daemon in a loop with configurable interval (default 1 hour)."""
|
||||
logger.info("Daemon started (interval=%ds)", interval)
|
||||
while True:
|
||||
run_once()
|
||||
time.sleep(interval)
|
||||
Reference in New Issue
Block a user