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>
This commit is contained in:
38
cmd/mcproxyctl/health.go
Normal file
38
cmd/mcproxyctl/health.go
Normal file
@@ -0,0 +1,38 @@
|
||||
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
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user