server: fix the 'starting API server' log to be in correct place

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5198
GitOrigin-RevId: a70477086778697d04042a779e77a8fd74220d2d
This commit is contained in:
Anon Ray 2022-10-20 13:59:14 +05:30 committed by hasura-bot
parent 754fb6e8b9
commit e22b3816d9

View File

@ -591,8 +591,9 @@ runHGEServer ::
ManagedT m () ManagedT m ()
runHGEServer setupHook env serveOptions serveCtx initTime postPollHook serverMetrics ekgStore startupStatusHook prometheusMetrics = do runHGEServer setupHook env serveOptions serveCtx initTime postPollHook serverMetrics ekgStore startupStatusHook prometheusMetrics = do
waiApplication <- waiApplication <-
mkHGEServer setupHook env serveOptions serveCtx initTime postPollHook serverMetrics ekgStore prometheusMetrics mkHGEServer setupHook env serveOptions serveCtx postPollHook serverMetrics ekgStore prometheusMetrics
let logger = _lsLogger $ _scLoggers serveCtx
-- `startupStatusHook`: add `Service started successfully` message to config_status -- `startupStatusHook`: add `Service started successfully` message to config_status
-- table when a tenant starts up in multitenant -- table when a tenant starts up in multitenant
let warpSettings :: Warp.Settings let warpSettings :: Warp.Settings
@ -626,10 +627,14 @@ runHGEServer setupHook env serveOptions serveCtx initTime postPollHook serverMet
shutdownHandler closeSocket = shutdownHandler closeSocket =
LA.link =<< LA.async do LA.link =<< LA.async do
waitForShutdown $ _scShutdownLatch serveCtx waitForShutdown $ _scShutdownLatch serveCtx
let logger = _lsLogger $ _scLoggers serveCtx
unLogger logger $ mkGenericStrLog LevelInfo "server" "gracefully shutting down server" unLogger logger $ mkGenericStrLog LevelInfo "server" "gracefully shutting down server"
closeSocket closeSocket
finishTime <- liftIO Clock.getCurrentTime
let apiInitTime = realToFrac $ Clock.diffUTCTime finishTime initTime
unLogger logger $
mkGenericLog LevelInfo "server" $ StartupTimeInfo "starting API server" apiInitTime
-- Here we block until the shutdown latch 'MVar' is filled, and then -- Here we block until the shutdown latch 'MVar' is filled, and then
-- shut down the server. Once this blocking call returns, we'll tidy up -- shut down the server. Once this blocking call returns, we'll tidy up
-- any resources using the finalizers attached using 'ManagedT' above. -- any resources using the finalizers attached using 'ManagedT' above.
@ -668,14 +673,12 @@ mkHGEServer ::
ServeCtx -> ServeCtx ->
-- and mutations -- and mutations
-- | start time
UTCTime ->
Maybe ES.SubscriptionPostPollHook -> Maybe ES.SubscriptionPostPollHook ->
ServerMetrics -> ServerMetrics ->
EKG.Store EKG.EmptyMetrics -> EKG.Store EKG.EmptyMetrics ->
PrometheusMetrics -> PrometheusMetrics ->
ManagedT m Application ManagedT m Application
mkHGEServer setupHook env ServeOptions {..} ServeCtx {..} initTime postPollHook serverMetrics ekgStore prometheusMetrics = do mkHGEServer setupHook env ServeOptions {..} ServeCtx {..} postPollHook serverMetrics ekgStore prometheusMetrics = do
-- Comment this to enable expensive assertions from "GHC.AssertNF". These -- Comment this to enable expensive assertions from "GHC.AssertNF". These
-- will log lines to STDOUT containing "not in normal form". In the future we -- 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 -- could try to integrate this into our tests. For now this is a development
@ -826,11 +829,6 @@ mkHGEServer setupHook env ServeOptions {..} ServeCtx {..} initTime postPollHook
return $ Just telemetryThread return $ Just telemetryThread
else return Nothing else return Nothing
finishTime <- liftIO Clock.getCurrentTime
let apiInitTime = realToFrac $ Clock.diffUTCTime finishTime initTime
unLogger logger $
mkGenericLog LevelInfo "server" $ StartupTimeInfo "starting API server" apiInitTime
-- These cleanup actions are not directly associated with any -- These cleanup actions are not directly associated with any
-- resource, but we still need to make sure we clean them up here. -- resource, but we still need to make sure we clean them up here.
allocate_ (pure ()) (liftIO stopWsServer) allocate_ (pure ()) (liftIO stopWsServer)