MCPcopy Create free account
hub / github.com/Coooolfan/onlyboxes / wait_worker_online

Function wait_worker_online

scripts/install.py:650–678  ·  view source on GitHub ↗
(
    http_port: int, worker_id: str, api_key: str, plan: DeploymentPlan,
)

Source from the content-addressed store, hash-verified

648
649
650def wait_worker_online(
651 http_port: int, worker_id: str, api_key: str, plan: DeploymentPlan,
652) -> None:
653 url = f"http://127.0.0.1:{http_port}/api/v1/workers?status=online&page=1&page_size=100"
654 deadline = time.monotonic() + WORKER_ONLINE_TIMEOUT
655 while time.monotonic() < deadline:
656 try:
657 result = api_request(url, api_key=api_key)
658 workers = result.get("items") or []
659 for w in workers:
660 if w.get("node_id") == worker_id:
661 info("Worker is online!")
662 return
663 except SystemExit:
664 pass
665 time.sleep(POLL_INTERVAL)
666
667 if plan.worker_start == "systemd":
668 hint = (
669 f" Check status: systemctl status {plan.worker_service_name}\n"
670 f" Check logs: journalctl -u {plan.worker_service_name} -n 200 --no-pager"
671 )
672 else:
673 hint = " Check the terminal output above for errors."
674
675 fatal(
676 "worker-online",
677 f"Worker {worker_id} did not come online within {WORKER_ONLINE_TIMEOUT}s.\n{hint}",
678 )
679
680
681# ---------------------------------------------------------------------------

Callers 1

mainFunction · 0.85

Calls 3

api_requestFunction · 0.85
infoFunction · 0.85
fatalFunction · 0.70

Tested by

no test coverage detected