From 6871a695b41e930a5c2a981f31e80b6cf6629aa4 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 30 Apr 2019 20:44:54 +0200 Subject: [PATCH] 500 instead of 204 when no report is available for too long --- src/Handler/Health.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Handler/Health.hs b/src/Handler/Health.hs index ecc16589d..d21b7734a 100644 --- a/src/Handler/Health.hs +++ b/src/Handler/Health.hs @@ -12,7 +12,13 @@ getHealthR :: Handler TypedContent getHealthR = do healthReport' <- liftIO . readTVarIO =<< getsYesod appHealthReport case healthReport' of - Nothing -> sendResponseStatus noContent204 () + Nothing -> do + interval <- getsYesod $ round . (* 1e6) . toRational . view _appHealthCheckInterval + reportStore <- getsYesod appHealthReport + waitResult <- threadDelay interval `race` atomically (readTVar reportStore >>= guard . is _Just) + case waitResult of + Left () -> fail "System is not generating HealthReports" + Right _ -> redirect HealthR Just (lastUpdated, healthReport) -> do rContent <- selectRep $ do provideRep $