feat(us-016): connection/heartbeat visibility for tracker and node

Tracker now prints a line when a node registers and on every heartbeat
received. Node prints its assigned node_id after successful registration
and starts a daemon heartbeat thread (30s interval) that logs each send.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Dobromir Popov
2026-06-30 00:41:10 +03:00
parent a7cc377d13
commit 97eefd3d5e
2 changed files with 38 additions and 2 deletions

View File

@@ -656,6 +656,13 @@ class _TrackerHandler(http.server.BaseHTTPRequestHandler):
if assignment_directive is not None:
entry.pending_directives.clear()
shard_info = f"layers {shard_start}-{shard_end}" if shard_start is not None else "unsharded"
repo_info = f" [{hf_repo}]" if hf_repo else ""
print(
f"[tracker] node registered: {node_id[:8]} {endpoint} {model}{repo_info} {shard_info}",
flush=True,
)
payload = {"node_id": node_id}
if assignment_directive is not None:
payload["directive"] = assignment_directive
@@ -673,6 +680,10 @@ class _TrackerHandler(http.server.BaseHTTPRequestHandler):
_rebalance_model_locked(server, entry.model or "stub-model")
directives = list(entry.pending_directives)
entry.pending_directives.clear()
print(
f"[tracker] heartbeat: {node_id[:8]} {entry.endpoint}",
flush=True,
)
if directives:
self._send_json(200, {"directives": directives})
else: