Skip to content

cmd: Add 'caddy status' command and core StatusReporter interface#7506

Open
pauloappbr wants to merge 1 commit intocaddyserver:masterfrom
pauloappbr:feature/issue-7453-status-command
Open

cmd: Add 'caddy status' command and core StatusReporter interface#7506
pauloappbr wants to merge 1 commit intocaddyserver:masterfrom
pauloappbr:feature/issue-7453-status-command

Conversation

@pauloappbr
Copy link
Contributor

Assistance Disclosure

I used an LLM (Gemini) as a pair-programming assistant to brainstorm the architecture, design the StatusReporter interface, 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/pprof logic, setting the ground for app-specific metrics.

What this PR does:

  1. Extensibility: Introduces the StatusReporter interface in the core caddy package. Any App or Module can implement this interface to safely expose its internal status snapshot.
  2. Admin API: Adds the GET /status endpoint. It loops through the ActiveContext() loaded apps, aggregating basic process data (Uptime, Memory, Goroutines, Version) and dynamically appending any app-specific status if the app implements StatusReporter.
  3. CLI: Adds the caddy status command. By default, it outputs a human-readable summary of the JSON payload. The --json flag is available for raw output.

Future Work (Phase 2):

Implementing the StatusReporter interface specifically inside the http app to track active requests, latency, and the dot-matrix scoreboard, leveraging existing Prometheus hooks.

Demo:

Standard Output:

Caddy v2.x.x
Status: Running
Uptime: 14m 32s

Running apps: http, tls

Memory
Allocated: 4 MB
System: 19 MB
Goroutines: 18

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"
}

@pauloappbr pauloappbr force-pushed the feature/issue-7453-status-command branch from bef5ce6 to b608c19 Compare February 21, 2026 13:03
@mholt
Copy link
Member

mholt commented Mar 5, 2026

Thanks for the PR! I'm excited to clone this down and kick it around a bit.

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.

2 participants