Manager: actually return worker state in /api/worker/state endpoint

This commit is contained in:
Sybren A. Stüvel 2022-02-15 15:56:38 +01:00
parent d6df00db3e
commit 93517549b0

View File

@ -160,8 +160,15 @@ func (f *Flamenco) SignOff(e echo.Context) error {
// (GET /api/worker/state)
func (f *Flamenco) WorkerState(e echo.Context) error {
// TODO: look up proper status in DB.
return e.String(http.StatusNoContent, "")
worker := requestWorkerOrPanic(e)
if worker.StatusRequested == "" {
return e.String(http.StatusNoContent, "")
}
return e.JSON(http.StatusOK, api.WorkerStateChange{
StatusRequested: worker.StatusRequested,
})
}
// Worker changed state. This could be as acknowledgement of a Manager-requested state change, or in response to worker-local signals.