Fix admin-info, admin-status json status field (#2293)
This commit is contained in:
committed by
kannappanr
parent
017dddef97
commit
e1056aa50d
+5
-5
@@ -94,7 +94,7 @@ type ServerInfo struct {
|
||||
// infoMessage container to hold service status information.
|
||||
type infoMessage struct {
|
||||
Status string `json:"status"`
|
||||
Service bool `json:"service"`
|
||||
Service string `json:"service"`
|
||||
Addr string `json:"address"`
|
||||
Err string `json:"error"`
|
||||
*ServerInfo
|
||||
@@ -109,7 +109,7 @@ func (u infoMessage) String() (msg string) {
|
||||
dot := "●"
|
||||
|
||||
// When service is offline
|
||||
if !u.Service {
|
||||
if u.Service == "off" {
|
||||
msg += fmt.Sprintf("%s %s\n", console.Colorize("InfoFail", dot), u.Addr)
|
||||
msg += fmt.Sprintf(" Uptime : Server is %s", console.Colorize("InfoFail", "offline"))
|
||||
return
|
||||
@@ -204,7 +204,7 @@ func mainAdminInfo(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
if serviceOffline {
|
||||
printMsg(infoMessage{Addr: aliasedURL, Service: false})
|
||||
printMsg(infoMessage{Addr: aliasedURL, Service: "off"})
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ func mainAdminInfo(ctx *cli.Context) error {
|
||||
// Print the error if exists and jump to the next server
|
||||
if serverInfo.Error != "" {
|
||||
printMsg(infoMessage{
|
||||
Service: true,
|
||||
Service: "on",
|
||||
Addr: serverInfo.Addr,
|
||||
Err: serverInfo.Error,
|
||||
})
|
||||
@@ -241,7 +241,7 @@ func mainAdminInfo(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
printMsg(infoMessage{
|
||||
Service: true,
|
||||
Service: "on",
|
||||
Addr: serverInfo.Addr,
|
||||
Err: serverInfo.Error,
|
||||
ServerInfo: &ServerInfo{
|
||||
|
||||
@@ -56,7 +56,7 @@ EXAMPLES:
|
||||
// serviceStatusMessage container to hold service status information.
|
||||
type serviceStatusMessage struct {
|
||||
Status string `json:"status"`
|
||||
Service bool `json:"service"`
|
||||
Service string `json:"service"`
|
||||
Uptime time.Duration `json:"uptime"`
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func (u serviceStatusMessage) String() (msg string) {
|
||||
msg = console.Colorize("ServiceStatus", msg)
|
||||
}()
|
||||
// When service is offline
|
||||
if !u.Service {
|
||||
if u.Service == "off" {
|
||||
msg = "The server is offline."
|
||||
return
|
||||
}
|
||||
@@ -76,7 +76,13 @@ func (u serviceStatusMessage) String() (msg string) {
|
||||
|
||||
// JSON jsonified service status Message message.
|
||||
func (u serviceStatusMessage) JSON() string {
|
||||
u.Status = "success"
|
||||
switch u.Service {
|
||||
case "on":
|
||||
u.Status = "success"
|
||||
case "off":
|
||||
u.Status = "failure"
|
||||
}
|
||||
|
||||
statusJSONBytes, e := json.Marshal(u)
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
@@ -120,7 +126,7 @@ func mainAdminServiceStatus(ctx *cli.Context) error {
|
||||
}
|
||||
}
|
||||
if serviceOffline {
|
||||
printMsg(serviceStatusMessage{Service: false})
|
||||
printMsg(serviceStatusMessage{Service: "off"})
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -129,7 +135,7 @@ func mainAdminServiceStatus(ctx *cli.Context) error {
|
||||
|
||||
// Print the whole response
|
||||
printMsg(serviceStatusMessage{
|
||||
Service: true,
|
||||
Service: "on",
|
||||
Uptime: st.Uptime,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user