Files
mc-proxy/cmd/mcproxyctl/health.go
Kyle Isom 666d55018c Add mcproxyctl CLI for gRPC admin API
Introduces a new command-line tool for managing mc-proxy via the gRPC
admin API over Unix socket. Commands include route and firewall rule
CRUD operations, health checks, and status queries.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-19 08:09:13 -07:00

39 lines
746 B
Go

package main
import (
"context"
"fmt"
"time"
"github.com/spf13/cobra"
"git.wntrmute.dev/kyle/mc-proxy/client/mcproxy"
)
func healthCmd() *cobra.Command {
return &cobra.Command{
Use: "health",
Short: "Check server health",
Long: "Check the health status of the mc-proxy server.",
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.CheckHealth(ctx)
if err != nil {
return fmt.Errorf("checking health: %w", err)
}
fmt.Println(status)
if status != mcproxy.HealthServing {
return fmt.Errorf("server is not healthy")
}
return nil
},
}
}