Files
mc-proxy/cmd/mcproxyctl/status.go
Kyle Isom 6dc3e18925 Add per-route details to status, move socket to /srv/mc-proxy/
mcproxyctl status now shows individual routes per listener with
hostname, backend, mode, and re-encrypt indicator. Proto, gRPC
server, client library, and CLI all updated.

Default gRPC socket path moved from /var/run/mc-proxy.sock to
/srv/mc-proxy/mc-proxy.sock to match the service data directory
convention.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 12:52:37 -07:00

54 lines
1.2 KiB
Go

package main
import (
"context"
"fmt"
"time"
"github.com/spf13/cobra"
)
func statusCmd() *cobra.Command {
return &cobra.Command{
Use: "status",
Short: "Show server status",
Long: "Show server status including version, uptime, and listener information.",
RunE: func(cmd *cobra.Command, args []string) error {
client := clientFromContext(cmd.Context())
ctx, cancel := context.WithTimeout(cmd.Context(), 5*time.Second)
defer cancel()
status, err := client.GetStatus(ctx)
if err != nil {
return fmt.Errorf("getting status: %w", err)
}
fmt.Printf("mc-proxy %s\n", status.Version)
if !status.StartedAt.IsZero() {
uptime := time.Since(status.StartedAt).Truncate(time.Second)
fmt.Printf("uptime: %s\n", uptime)
}
fmt.Printf("connections: %d\n", status.TotalConnections)
fmt.Println()
for _, ls := range status.Listeners {
fmt.Printf(" %s routes=%d active=%d\n", ls.Addr, ls.RouteCount, ls.ActiveConnections)
for _, r := range ls.Routes {
mode := r.Mode
if mode == "" {
mode = "l4"
}
extra := ""
if r.BackendTLS {
extra = " (re-encrypt)"
}
fmt.Printf(" %s %s → %s%s\n", mode, r.Hostname, r.Backend, extra)
}
}
return nil
},
}
}