healthWidgetMemcached
This commit is contained in:
parent
667677731e
commit
32512db3cb
@ -15,7 +15,7 @@ import qualified Data.ByteArray as ByteArray
|
|||||||
|
|
||||||
import Utils.Lens
|
import Utils.Lens
|
||||||
|
|
||||||
import Network.HTTP.Simple (httpJSON)
|
import Network.HTTP.Simple (httpJSON, httpLBS)
|
||||||
import qualified Network.HTTP.Simple as HTTP
|
import qualified Network.HTTP.Simple as HTTP
|
||||||
|
|
||||||
import qualified Database.Esqueleto as E
|
import qualified Database.Esqueleto as E
|
||||||
@ -35,6 +35,7 @@ generateHealthReport
|
|||||||
<*> Concurrently httpReachable
|
<*> Concurrently httpReachable
|
||||||
<*> Concurrently ldapAdmins
|
<*> Concurrently ldapAdmins
|
||||||
<*> Concurrently smtpConnect
|
<*> Concurrently smtpConnect
|
||||||
|
<*> Concurrently widgetMemcached
|
||||||
|
|
||||||
matchingClusterConfig :: Handler Bool
|
matchingClusterConfig :: Handler Bool
|
||||||
-- ^ Can the cluster configuration be read from the database and does it match our configuration?
|
-- ^ Can the cluster configuration be read from the database and does it match our configuration?
|
||||||
@ -117,3 +118,22 @@ smtpConnect = do
|
|||||||
_ -> do
|
_ -> do
|
||||||
$logErrorS "Mail" $ "NOOP failed: " <> tshow response
|
$logErrorS "Mail" $ "NOOP failed: " <> tshow response
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
widgetMemcached :: Handler (Maybe Bool)
|
||||||
|
widgetMemcached = do
|
||||||
|
memcachedConn <- getsYesod appWidgetMemcached
|
||||||
|
for memcachedConn $ \_memcachedConn' -> do
|
||||||
|
let ext = "bin"
|
||||||
|
mimeType = "application/octet-stream"
|
||||||
|
content <- pack . take 256 <$> liftIO getRandoms
|
||||||
|
staticLink <- addStaticContent ext mimeType content
|
||||||
|
case staticLink of
|
||||||
|
Just (Left url) -> do
|
||||||
|
baseRequest <- HTTP.parseRequest $ unpack url
|
||||||
|
httpManager <- getsYesod appHttpManager
|
||||||
|
let httpRequest = baseRequest
|
||||||
|
& HTTP.setRequestManager httpManager
|
||||||
|
(== content) . responseBody <$> httpLBS httpRequest
|
||||||
|
_other -> return False
|
||||||
|
|
||||||
|
|||||||
@ -939,6 +939,8 @@ data HealthReport = HealthReport
|
|||||||
-- Is `Nothing` if LDAP is not configured or no users are school admins
|
-- Is `Nothing` if LDAP is not configured or no users are school admins
|
||||||
, healthSMTPConnect :: Maybe Bool
|
, healthSMTPConnect :: Maybe Bool
|
||||||
-- ^ Can we connect to the SMTP server and say @NOOP@?
|
-- ^ Can we connect to the SMTP server and say @NOOP@?
|
||||||
|
, healthWidgetMemcached :: Maybe Bool
|
||||||
|
-- ^ Can we store values in memcached and retrieve them via HTTP?
|
||||||
} deriving (Eq, Ord, Read, Show, Generic, Typeable)
|
} deriving (Eq, Ord, Read, Show, Generic, Typeable)
|
||||||
|
|
||||||
deriveJSON defaultOptions
|
deriveJSON defaultOptions
|
||||||
@ -970,6 +972,7 @@ classifyHealthReport HealthReport{..} = getMin . execWriter $ do -- Construction
|
|||||||
unless (fromMaybe True healthHTTPReachable) . tell $ Min HealthFailure
|
unless (fromMaybe True healthHTTPReachable) . tell $ Min HealthFailure
|
||||||
unless (maybe True (> 0) healthLDAPAdmins) . tell $ Min HealthFailure
|
unless (maybe True (> 0) healthLDAPAdmins) . tell $ Min HealthFailure
|
||||||
unless (fromMaybe True healthSMTPConnect) . tell $ Min HealthFailure
|
unless (fromMaybe True healthSMTPConnect) . tell $ Min HealthFailure
|
||||||
|
unless (fromMaybe True healthWidgetMemcached) . tell $ Min HealthFailure
|
||||||
|
|
||||||
|
|
||||||
-- Type synonyms
|
-- Type synonyms
|
||||||
|
|||||||
Reference in New Issue
Block a user