Skip to content

Commit

Permalink
update checks on ci systems (close #319) (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahidhk authored Sep 12, 2018
1 parent fffaed7 commit be20a11
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions server/src-lib/Hasura/Server/CheckUpdates.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Hasura.Server.CheckUpdates
import Control.Exception (try)
import Control.Lens
import Control.Monad (forever)
import System.Environment (lookupEnv)

import qualified Control.Concurrent as C
import qualified Data.Aeson as A
Expand Down Expand Up @@ -35,7 +36,7 @@ checkForUpdates (LoggerCtx loggerSet _ _) manager = do
let options = Wreq.defaults
& Wreq.checkResponse ?~ (\_ _ -> return ())
& Wreq.manager .~ Right manager

url <- getUrl
forever $ do
resp <- try $ Wreq.getWith options $ T.unpack url
case resp of
Expand All @@ -49,8 +50,16 @@ checkForUpdates (LoggerCtx loggerSet _ _) manager = do

where
updateMsg v = "Update: A new version is available: " <> v
url = "https://releases.hasura.io/graphql-engine?agent=server&version="
<> currentVersion
getUrl = do
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

-- ignoring if there is any error in response and returning the current version
Expand Down

0 comments on commit be20a11

Please sign in to comment.