Add tick information to server status
This commit is contained in:
parent
6ac5a559b5
commit
db38ad6091
3 changed files with 16 additions and 4 deletions
|
@ -105,6 +105,8 @@ func InnerMain(command string) error {
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("Ready: %t\n", response.Ready)
|
fmt.Printf("Ready: %t\n", response.Ready)
|
||||||
fmt.Printf("Version: %s\n", response.Version)
|
fmt.Printf("Version: %s\n", response.Version)
|
||||||
|
fmt.Printf("Tick: %d\n", response.Tick)
|
||||||
|
fmt.Printf("Next Tick: %s\n", response.NextTick)
|
||||||
}
|
}
|
||||||
|
|
||||||
case "register":
|
case "register":
|
||||||
|
|
|
@ -17,8 +17,10 @@ func (s Server) Status() (r StatusResponse, err error) {
|
||||||
|
|
||||||
// StatusResponse is a struct that contains information on the status of the server
|
// StatusResponse is a struct that contains information on the status of the server
|
||||||
type StatusResponse struct {
|
type StatusResponse struct {
|
||||||
Ready bool `json:"ready"`
|
Ready bool `json:"ready"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
|
Tick int `json:"tick"`
|
||||||
|
NextTick string `json:"nexttick,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==============================
|
// ==============================
|
||||||
|
|
|
@ -59,10 +59,18 @@ var Routes = []Route{
|
||||||
func HandleStatus(s *Server, vars map[string]string, b io.ReadCloser, w io.Writer) (interface{}, error) {
|
func HandleStatus(s *Server, vars map[string]string, b io.ReadCloser, w io.Writer) (interface{}, error) {
|
||||||
|
|
||||||
// Simply return the current server status
|
// Simply return the current server status
|
||||||
return rove.StatusResponse{
|
response := rove.StatusResponse{
|
||||||
Ready: true,
|
Ready: true,
|
||||||
Version: version.Version,
|
Version: version.Version,
|
||||||
}, nil
|
Tick: s.tick,
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there's a schedule, respond with it
|
||||||
|
if len(s.schedule.Entries()) > 0 {
|
||||||
|
response.NextTick = s.schedule.Entries()[0].Next.Format("15:04:05")
|
||||||
|
}
|
||||||
|
|
||||||
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandleRegister handles /register endpoint
|
// HandleRegister handles /register endpoint
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue