(
http_port: int, worker_id: str, api_key: str, plan: DeploymentPlan,
)
| 648 | |
| 649 | |
| 650 | def 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 | # --------------------------------------------------------------------------- |
no test coverage detected