Files
getDomain/domain-api/app/sync_agent.py
Your Name ebf632e651 first
2026-04-16 21:35:47 +08:00

38 lines
1.0 KiB
Python

from __future__ import annotations
import logging
import time
from app.core.config import settings
from app.services.sync_push_service import push_runtime_projection_now
logger = logging.getLogger("domaincheck.sync_agent")
def main() -> None:
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
)
interval = max(10, int(settings.sync_poll_interval_seconds or 30))
logger.info(
"sync agent started: node=%s source=%s target=%s interval=%ss enabled=%s",
settings.node_code,
settings.sync_source_region,
settings.sync_target_region,
interval,
settings.sync_push_enabled,
)
while True:
try:
ok, message, data = push_runtime_projection_now()
logger.info("sync tick: ok=%s message=%s data=%s", ok, message, data)
except Exception as exc:
logger.exception("sync tick failed: %s", exc)
time.sleep(interval)
if __name__ == "__main__":
main()