iris: pin tunnel port scan to start at 10000#3679
Conversation
Makes the dashboard port stable across restarts so developers can bookmark or refresh the page without hunting for a new port each time. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @Helw150's task in 40s —— View job Review of PR #3679
LGTM — clean, minimal change. The diff passes No issues found. The change is consistent across both platforms and the |
|
I like this (I had it originally) but @dlwh bots would try to open multiple tunnels in parallel and then stomp on each other. Maybe someone has a suggestion for how to avoid the stomping? We could fnctl a lock file while the tunnel is being setup? @claude what do you think, could you make a lock around the port scan, maybe /tmp/iris/port_NNNNN with the pid? could you make that less than 5 lines? |
|
Claude finished @rjpower's task in 2m 56s —— View job Implementing port lock mechanism
Added PID-based lock files to
lock = Path(f"/tmp/iris/port_{port}")
try:
os.kill(int(lock.read_text()), 0)
continue # port locked by a live process
except (FileNotFoundError, ValueError, ProcessLookupError, PermissionError):
pass
# ... after successful bind:
lock.parent.mkdir(parents=True, exist_ok=True)
lock.write_text(str(os.getpid()))Testing: |
When multiple tunnels are opened in parallel, they can race on find_free_port and grab the same port. Write a lock file at /tmp/iris/port_NNNNN with the owning PID and skip ports held by live processes on subsequent scans. Co-authored-by: Russell Power <rjpower@users.noreply.github.com>
Hmmm, I need to think through why the agents were setting up multiple dashboards. My agent tends to just query Iris directly (though upon second reflection, maybe I'm being dumb and this code path effects commands like job logs too) |
|
Well, the fix is fine anyhow!! |
|
Claude finished @Helw150's task in 58s —— View job Analysis: tunnel usage and port contention
You're right to think this through — the tunnel code path is used by every CLI command that talks to the controller, not just the dashboard. Looking at So yes, @rjpower's concern is valid: if you run The PID lock file mechanism that was already pushed handles this correctly:
The lock files are self-cleaning (stale PIDs from dead processes are ignored via One minor note: the lock is written after the socket is closed ( |
|
Yeah for whatever reason codex seemed to like to list tasks, log and list jobs all at once... |
Makes the dashboard port stable across restarts so developers can bookmark or refresh the page copy-pasting the new port each time.