mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-08-16 06:00:34 +03:00
parent
fffaed7bcb
commit
be20a11d37
@ -8,6 +8,7 @@ module Hasura.Server.CheckUpdates
|
|||||||
import Control.Exception (try)
|
import Control.Exception (try)
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Control.Monad (forever)
|
import Control.Monad (forever)
|
||||||
|
import System.Environment (lookupEnv)
|
||||||
|
|
||||||
import qualified Control.Concurrent as C
|
import qualified Control.Concurrent as C
|
||||||
import qualified Data.Aeson as A
|
import qualified Data.Aeson as A
|
||||||
@ -35,7 +36,7 @@ checkForUpdates (LoggerCtx loggerSet _ _) manager = do
|
|||||||
let options = Wreq.defaults
|
let options = Wreq.defaults
|
||||||
& Wreq.checkResponse ?~ (\_ _ -> return ())
|
& Wreq.checkResponse ?~ (\_ _ -> return ())
|
||||||
& Wreq.manager .~ Right manager
|
& Wreq.manager .~ Right manager
|
||||||
|
url <- getUrl
|
||||||
forever $ do
|
forever $ do
|
||||||
resp <- try $ Wreq.getWith options $ T.unpack url
|
resp <- try $ Wreq.getWith options $ T.unpack url
|
||||||
case resp of
|
case resp of
|
||||||
@ -49,8 +50,16 @@ checkForUpdates (LoggerCtx loggerSet _ _) manager = do
|
|||||||
|
|
||||||
where
|
where
|
||||||
updateMsg v = "Update: A new version is available: " <> v
|
updateMsg v = "Update: A new version is available: " <> v
|
||||||
url = "https://releases.hasura.io/graphql-engine?agent=server&version="
|
getUrl = do
|
||||||
<> currentVersion
|
let buildUrl a = "https://releases.hasura.io/graphql-engine?agent="
|
||||||
|
<> a
|
||||||
|
<> "&version="
|
||||||
|
<> currentVersion
|
||||||
|
isCI <- lookupEnv "CI"
|
||||||
|
case isCI of
|
||||||
|
Just "true" -> return $ buildUrl "server-ci"
|
||||||
|
_ -> return $ buildUrl "server"
|
||||||
|
|
||||||
aDay = 86400 * 1000 * 1000
|
aDay = 86400 * 1000 * 1000
|
||||||
|
|
||||||
-- ignoring if there is any error in response and returning the current version
|
-- ignoring if there is any error in response and returning the current version
|
||||||
|
Loading…
Reference in New Issue
Block a user