这是indexloc提供的服务,不要输入任何密码
Skip to content

update checks on ci systems (close #319) #383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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