cmd: Add 'caddy status' command and core StatusReporter interface#7506
Open
pauloappbr wants to merge 1 commit intocaddyserver:masterfrom
Open
cmd: Add 'caddy status' command and core StatusReporter interface#7506pauloappbr wants to merge 1 commit intocaddyserver:masterfrom
pauloappbr wants to merge 1 commit intocaddyserver:masterfrom
Conversation
bef5ce6 to
b608c19
Compare
Member
|
Thanks for the PR! I'm excited to clone this down and kick it around a bit. |
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.
Assistance Disclosure
I used an LLM (Gemini) as a pair-programming assistant to brainstorm the architecture, design the
StatusReporterinterface, and generate the initial Go code structure. I then compiled, debugged, and manually verified the correctness of the code locally to ensure it meets Caddy's standards.Resolves Phase 1 of #7453.
As discussed in the issue, this PR introduces the core architecture and the CLI command to view the running status of a Caddy instance without duplicating
/debug/pproflogic, setting the ground for app-specific metrics.What this PR does:
StatusReporterinterface in the corecaddypackage. Any App or Module can implement this interface to safely expose its internal status snapshot.GET /statusendpoint. It loops through theActiveContext()loaded apps, aggregating basic process data (Uptime, Memory, Goroutines, Version) and dynamically appending any app-specific status if the app implementsStatusReporter.caddy statuscommand. By default, it outputs a human-readable summary of the JSON payload. The--jsonflag is available for raw output.Future Work (Phase 2):
Implementing the
StatusReporterinterface specifically inside thehttpapp to track active requests, latency, and the dot-matrix scoreboard, leveraging existing Prometheus hooks.Demo:
Standard Output:
JSON Output (
caddy status --json):{ "apps": { "http": {"status":"running"}, "tls": {"status":"running"} }, "goroutines": 18, "memory": { "allocated_bytes": 4071992, "system_bytes": 19749128 }, "uptime_secs": 872.4, "version": "v2.x.x" }