first
This commit is contained in:
37
domain-api/app/sync_agent.py
Normal file
37
domain-api/app/sync_agent.py
Normal file
@@ -0,0 +1,37 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user