Files
service-finder/backend/app/services/robot_manager.py

37 lines
1.2 KiB
Python

# /app/services/robot_manager.py
import asyncio
import logging
from datetime import datetime
from .harvester_cars import CarHarvester
# Megjegyzés: Ellenőrizd, hogy a harvester_bikes/trucks fájlokban is BaseHarvester az alap!
logger = logging.getLogger(__name__)
class RobotManager:
@staticmethod
async def run_full_sync(db):
"""Sorban lefuttatja a robotokat az új AssetCatalog struktúrához."""
logger.info(f"🕒 Teljes szinkronizáció indítva: {datetime.now()}")
robots = [
CarHarvester(),
# BikeHarvester(),
# TruckHarvester()
]
for robot in robots:
try:
await robot.run(db)
logger.info(f"{robot.category} robot sikeresen lefutott.")
await asyncio.sleep(5)
except Exception as e:
logger.error(f"❌ Kritikus hiba a {robot.category} robotnál: {e}")
@staticmethod
async def schedule_nightly_run(db):
while True:
now = datetime.now()
if now.hour == 2 and now.minute == 0:
await RobotManager.run_full_sync(db)
await asyncio.sleep(70)
await asyncio.sleep(30)