Files
mc-proxy/cmd/mcproxyctl/health.go
Kyle Isom feeadc582b Migrate module path from kyle/ to mc/ org
All import paths updated to git.wntrmute.dev/mc/. Bumps mcdsl to v1.2.0.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 02:05:59 -07:00

39 lines
744 B
Go

package main
import (
"context"
"fmt"
"time"
"github.com/spf13/cobra"
"git.wntrmute.dev/mc/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
},
}
}