Skip to content
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

server: Pass EKG Metrics Store as argument to runHGEServer #5560

Merged
merged 5 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions server/graphql-engine.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ executable graphql-engine
, text
, text-conversions
, unix
, ekg-core

test-suite graphql-engine-tests
import: common-all, common-exe
Expand Down
5 changes: 4 additions & 1 deletion server/src-exec/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import qualified Database.PG.Query as Q
import qualified Hasura.Tracing as Tracing
import qualified System.Exit as Sys
import qualified System.Posix.Signals as Signals
import qualified System.Metrics as EKG


main :: IO ()
main = do
Expand All @@ -40,6 +42,7 @@ runApp env (HGEOptionsG rci hgeCmd) =
withVersion $$(getVersionFromEnvironment) $ case hgeCmd of
HCServe serveOptions -> do
(initCtx, initTime) <- initialiseCtx env hgeCmd rci
ekgStore <- liftIO EKG.newStore
let shutdownApp = return ()
-- Catches the SIGTERM signal and initiates a graceful shutdown.
-- Graceful shutdown for regular HTTP requests is already implemented in
Expand All @@ -50,7 +53,7 @@ runApp env (HGEOptionsG rci hgeCmd) =
Signals.sigTERM
(Signals.CatchOnce (shutdownGracefully initCtx))
Nothing
runHGEServer env serveOptions initCtx Nothing initTime shutdownApp Nothing
runHGEServer env serveOptions initCtx Nothing initTime shutdownApp Nothing ekgStore

HCExport -> do
(initCtx, _) <- initialiseCtx env hgeCmd rci
Expand Down
6 changes: 5 additions & 1 deletion server/src-lib/Hasura/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ import Hasura.Session
import qualified Hasura.GraphQL.Execute.LiveQuery.Poll as EL
import qualified Hasura.GraphQL.Transport.WebSocket.Server as WS
import qualified Hasura.Tracing as Tracing
import qualified System.Metrics as EKG


data ExitCode
= InvalidEnvironmentVariableOptionsError
Expand Down Expand Up @@ -308,8 +310,9 @@ runHGEServer
-> IO ()
-- ^ shutdown function
-> Maybe EL.LiveQueryPostPollHook
-> EKG.Store
-> m ()
runHGEServer env ServeOptions{..} InitCtx{..} pgExecCtx initTime shutdownApp postPollHook = do
runHGEServer env ServeOptions{..} InitCtx{..} pgExecCtx initTime shutdownApp postPollHook ekgStore = do
-- Comment this to enable expensive assertions from "GHC.AssertNF". These
-- will log lines to STDOUT containing "not in normal form". In the future we
-- could try to integrate this into our tests. For now this is a development
Expand Down Expand Up @@ -351,6 +354,7 @@ runHGEServer env ServeOptions{..} InitCtx{..} pgExecCtx initTime shutdownApp pos
soResponseInternalErrorsConfig
postPollHook
_icSchemaCache
ekgStore

-- log inconsistent schema objects
inconsObjs <- scInconsistentObjs <$> liftIO (getSCFromRef cacheRef)
Expand Down
5 changes: 2 additions & 3 deletions server/src-lib/Hasura/Server/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,10 @@ mkWaiApp
-> ResponseInternalErrorsConfig
-> Maybe EL.LiveQueryPostPollHook
-> (RebuildableSchemaCache Run, Maybe UTCTime)
-> EKG.Store
-> m HasuraApp
mkWaiApp env isoLevel logger sqlGenCtx enableAL pool pgExecCtxCustom ci httpManager mode corsCfg enableConsole consoleAssetsDir
enableTelemetry instanceId apis lqOpts planCacheOptions responseErrorsConfig liveQueryHook (schemaCache, cacheBuiltTime) = do
enableTelemetry instanceId apis lqOpts planCacheOptions responseErrorsConfig liveQueryHook (schemaCache, cacheBuiltTime) ekgStore = do

(planCache, schemaCacheRef) <- initialiseCache
let getSchemaCache = first lastBuiltSchemaCache <$> readIORef (_scrCache schemaCacheRef)
Expand All @@ -619,8 +620,6 @@ mkWaiApp env isoLevel logger sqlGenCtx enableAL pool pgExecCtxCustom ci httpMana
wsServerEnv <- WS.createWSServerEnv logger pgExecCtx lqState getSchemaCache httpManager
corsPolicy sqlGenCtx enableAL planCache

ekgStore <- liftIO EKG.newStore

let serverCtx = ServerCtx
{ scPGExecCtx = pgExecCtx
, scConnInfo = ci
Expand Down