Skip to content

Add robust server mode for coz plot - #267

Merged
emeryberger merged 2 commits into
masterfrom
robust-server-mode
Feb 15, 2026
Merged

Add robust server mode for coz plot#267
emeryberger merged 2 commits into
masterfrom
robust-server-mode

Conversation

@emeryberger

Copy link
Copy Markdown
Member

Summary

  • Auto-retry port selection: When the preferred port (default 8080) is busy, automatically tries the next 10 ports then random high ports, instead of failing with an error
  • Headless environment detection: Detects SSH sessions and missing display servers (X11/Wayland) to skip browser opening and print SSH port-forwarding instructions
  • --no-browser flag: Lets users explicitly start in server-only mode
  • Clean signal handling: Ctrl-C and SIGTERM now shut down the server reliably without deadlock

Test plan

  • coz plot — opens browser and serves on 8080 as before
  • Start two instances on same port — second auto-picks next available port with message
  • SSH_TTY=1 coz plot — prints port-forwarding hint, no browser opened
  • coz plot --no-browser — server starts without opening browser
  • Ctrl-C — server exits immediately with "Shutting down server..." message
  • kill -TERM <pid> — same clean shutdown

🤖 Generated with Claude Code

@emeryberger
emeryberger force-pushed the robust-server-mode branch 8 times, most recently from aac051a to 547292a Compare February 14, 2026 20:27
Make `coz plot` usable in headless/remote environments and more resilient
in local use:

- Auto-retry port selection when preferred port is busy (tries +0..+9
  then random high ports)
- Detect headless environments (SSH, no X11/Wayland) and skip browser
  opening, printing SSH port-forwarding instructions instead
- Add --no-browser flag for explicit server-only mode
- Fix Ctrl-C/SIGTERM handling to shut down cleanly without deadlock

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Ctrl-C (SIGINT) is unreliable in some shell environments (e.g. zsh on
macOS). Simply prompt for Enter, which always works via input().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@emeryberger
emeryberger merged commit f655e6d into master Feb 15, 2026
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant