-
Notifications
You must be signed in to change notification settings - Fork 218
Expand file tree
/
Copy pathdebug.go
More file actions
87 lines (76 loc) · 1.94 KB
/
debug.go
File metadata and controls
87 lines (76 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* Radon
*
* Copyright 2018 The Radon Authors.
* Code is licensed under the GPLv3.
*
*/
package cmd
import (
"fmt"
"xbase"
"github.com/spf13/cobra"
)
// NewDebugCommand creates new DebugCommand.
func NewDebugCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "debug",
Short: "show radon config, including configz/backendz/schemaz",
}
cmd.AddCommand(NewDebugConfigzCommand())
cmd.AddCommand(NewDebugBackendzCommand())
cmd.AddCommand(NewDebugSchemazCommand())
cmd.PersistentFlags().StringVar(&radonHost, "radon-host", "127.0.0.1", "--radon-host=[ip]")
return cmd
}
// NewDebugConfigzCommand is used to show config.
func NewDebugConfigzCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "configz",
Short: "show radon configz",
Run: debugConfigzCommand,
}
return cmd
}
func debugConfigzCommand(cmd *cobra.Command, args []string) {
configzURL := "http://" + radonHost + ":8080/v1/debug/configz"
resp, err := xbase.HTTPGet(configzURL)
if err != nil {
log.Panicf("error:%+v", err)
}
fmt.Print(resp)
}
// NewDebugBackendzCommand is used to show backend info.
func NewDebugBackendzCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "backendz",
Short: "show radon backendz",
Run: debugBackendzCommand,
}
return cmd
}
func debugBackendzCommand(cmd *cobra.Command, args []string) {
backendzURL := "http://" + radonHost + ":8080/v1/debug/backendz"
resp, err := xbase.HTTPGet(backendzURL)
if err != nil {
log.Panicf("error:%+v", err)
}
fmt.Print(resp)
}
// NewDebugSchemazCommand is used to show schema info.
func NewDebugSchemazCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "schemaz",
Short: "show radon schemaz",
Run: debugSchemazCommand,
}
return cmd
}
func debugSchemazCommand(cmd *cobra.Command, args []string) {
schemazURL := "http://" + radonHost + ":8080/v1/debug/schemaz"
resp, err := xbase.HTTPGet(schemazURL)
if err != nil {
log.Panicf("error:%+v", err)
}
fmt.Print(resp)
}