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 {
|
||||
fmt.Printf("Ready: %t\n", response.Ready)
|
||||
fmt.Printf("Version: %s\n", response.Version)
|
||||
fmt.Printf("Tick: %d\n", response.Tick)
|
||||
fmt.Printf("Next Tick: %s\n", response.NextTick)
|
||||
}
|
||||
|
||||
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
|
||||
type StatusResponse struct {
|
||||
Ready bool `json:"ready"`
|
||||
Version string `json:"version"`
|
||||
Ready bool `json:"ready"`
|
||||
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) {
|
||||
|
||||
// Simply return the current server status
|
||||
return rove.StatusResponse{
|
||||
response := rove.StatusResponse{
|
||||
Ready: true,
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue