500 instead of 204 when no report is available for too long

This commit is contained in:
Gregor Kleen 2019-04-30 20:44:54 +02:00
parent 32512db3cb
commit 6871a695b4

View File

@ -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 $