feat(monitor): attach dashboards to a background proxy - #134
Merged
Merged
Conversation
srnnkls
marked this pull request as ready for review
September 14, 2026 09:18
Plain services previously stopped listening after their first shutdown signal but could wait forever on a held connection because Tokio retains control of later signals. Listen for another Ctrl-C or SIGTERM while Axum drains so users can force termination without introducing a new timeout policy. Ensure the dedicated attachment client ignores ambient outbound proxy settings, since supported loopback and SSH-forward destinations are always direct. Carry service-computed uptime from a process-local monotonic clock in monitor snapshots, avoiding viewer clock skew. Add process-level signal coverage, a production binary proxy-environment test, and deterministic monotonic uptime assertions.
Returning from the graceful shutdown future still drops Tokio normally, which waits for active spawn_blocking work. Kimi performs blocking upstream requests with a long network timeout, so a second signal could still leave the process alive for minutes. Exit explicitly with status 130 after the second Ctrl-C or SIGTERM, matching the integrated monitor force-quit path while preserving graceful handling of the first signal. Exercise the production Kimi blocking path against a controlled upstream that accepts a request without responding, and require prompt forced termination while that worker remains active.
Bring the original PR and reviewed monitor corrections onto the current shared integration base without rebasing, so the contributor's exact PR head remains in history and the remote branch can advance by fast-forward. The only path changed by both sides was src/server.rs. Git combined the monitor route and connect-info listener with main's Anthropic request body limit, so both behaviors remain present without manual conflict resolution. Keep one signal receiver set alive across graceful shutdown. Re-registering between the first and second waits could consume signals ambiguously. Exercise both signal variants with an acknowledged production Kimi blocking request so the first signal has deterministic work to drain before the forced second exit.
The persistent signal abstraction discarded portable Ctrl-C listener failures outside Unix, which could misinterpret setup errors as two shutdown signals and force the process to exit with status 130 at startup. Own a persistent Tokio Windows CtrlC receiver created during fallible setup and propagate receive errors at both shutdown waits. Keep a result-preserving portable fallback for other targets and add a compile-time contract test for the constructor and receive future error types.
Owner
|
Thanks for this! Being able to attach a dashboard to a background proxy is useful. Merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Running the proxy as a service currently loses the interactive monitor: the TUI owns the listener, while plain mode does not collect monitor history. This adds
claude-code-proxy monitorto attach a dashboard to an existing proxy. Closing that dashboard leaves inference and other dashboards running.serve --no-monitormode and handle Ctrl-C/SIGTERM with graceful service shutdown.GET /monitor, restricted to actual loopback peers. Immutable read models carry elapsed durations and computed rates without reconstructing process-local clocks.qand Ctrl-C detach; dropping a dashboard cancels its polling task.The existing integrated
servedashboard keeps its shutdown behavior. History remains in memory and resets on service restart. Remote hosts can be reached through an SSH port forward. The attached dashboard needs no provider credentials and has no server mutation or shutdown endpoint.This branch is based directly on upstream
mainand is independent of #133.Validation
cargo fmt --check,cargo clippy --all-targets -- -D warnings, andcargo build --all-targets.cargo test --all-targets, including snapshot serialization, loopback access checks, multiple viewers, detach/reattach, polling failure/recovery, cancellation, and incompatible protocol handling.q, reattach and quit with Ctrl-C, verify HTTP health after each detach, then verify clean SIGTERM shutdown.Also ran the edition and Clippy fixers. Validation uses local mock servers; it makes no live provider requests.