Skip to content

Commit

Permalink
mkApp also returns finalizer for logs
Browse files Browse the repository at this point in the history
  • Loading branch information
smatting committed May 21, 2021
1 parent 36d532e commit 729234a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 7 additions & 5 deletions services/galley/src/Galley/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import qualified Wire.API.Routes.Public.Galley as GalleyAPI

run :: Opts -> IO ()
run o = do
(app, e) <- mkApp o
(app, e, appFinalizer) <- mkApp o
let l = e ^. App.applog
s <-
newSettings $
Expand All @@ -70,18 +70,20 @@ run o = do
Async.cancel deleteQueueThread
Async.cancel refreshMetricsThread
shutdown (e ^. cstate)
Log.flush l
Log.close l
appFinalizer

mkApp :: Opts -> IO (Application, Env)
mkApp :: Opts -> IO (Application, Env, IO ())
mkApp o = do
m <- M.metrics
e <- App.createEnv m o
let l = e ^. App.applog
validateOpts l o
runClient (e ^. cstate) $
versionCheck Data.schemaVersion
return (middlewares l m $ servantApp e, e)
let finalizer = do
Log.flush l
Log.close l
return (middlewares l m $ servantApp e, e, finalizer)
where
rtree = compile API.sitemap
app e r k = runGalley e r (route rtree r k)
Expand Down
4 changes: 3 additions & 1 deletion services/galley/test/integration/API/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Brig.Types
import Brig.Types.Intra (ConnectionStatus (ConnectionStatus), UserAccount (..))
import Brig.Types.Team.Invitation
import Brig.Types.User.Auth (CookieLabel (..))
import Control.Exception (finally)
import Control.Lens hiding (from, to, (#), (.=))
import Control.Monad.Catch (MonadCatch)
import Control.Retry (constantDelay, limitRetries, retrying)
Expand Down Expand Up @@ -1503,8 +1504,9 @@ defCookieLabel = CookieLabel "auth"
-- services will fail.
withSettingsOverrides :: MonadIO m => Opts.Opts -> WaiTest.Session a -> m a
withSettingsOverrides opts action = liftIO $ do
(galleyApp, _) <- Run.mkApp opts
(galleyApp, _, finalizer) <- Run.mkApp opts
WaiTest.runSession action galleyApp
`finally` liftIO finalizer

waitForMemberDeletion :: UserId -> TeamId -> UserId -> TestM ()
waitForMemberDeletion zusr tid uid = do
Expand Down

0 comments on commit 729234a

Please sign in to comment.