From 34777286d85c517287648342c5f336276266bcd0 Mon Sep 17 00:00:00 2001 From: Krushan Bauva Date: Wed, 16 Nov 2022 20:14:00 +0530 Subject: [PATCH] server: version command should be independent of any other flags PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6659 GitOrigin-RevId: 039e8150ad032b0187a7d8798667b736e5372937 --- server/src-exec/Main.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/src-exec/Main.hs b/server/src-exec/Main.hs index 78c0628e70c..905b37a7026 100644 --- a/server/src-exec/Main.hs +++ b/server/src-exec/Main.hs @@ -43,11 +43,10 @@ main = runApp :: Env.Environment -> HGEOptions (ServeOptions Hasura) -> IO () runApp env (HGEOptions rci metadataDbUrl hgeCmd) = do initTime <- liftIO getCurrentTime - globalCtx@GlobalCtx {..} <- initGlobalCtx env metadataDbUrl rci - let (maybeDefaultPgConnInfo, maybeRetries) = _gcDefaultPostgresConnInfo case hgeCmd of HCServe serveOptions -> do + globalCtx@GlobalCtx {} <- initGlobalCtx env metadataDbUrl rci (ekgStore, serverMetrics) <- liftIO $ do store <- EKG.newStore @AppMetricsSpec void $ EKG.register (EKG.subset GcSubset store) EKG.registerGcMetrics @@ -92,13 +91,17 @@ runApp env (HGEOptions rci metadataDbUrl hgeCmd) = do flip runPGMetadataStorageAppT (_scMetadataDbPool serveCtx, pgLogger) . lowerManagedT $ do runHGEServer (const $ pure ()) env serveOptions serveCtx initTime Nothing serverMetrics ekgStore Nothing prometheusMetrics HCExport -> do + GlobalCtx {..} <- initGlobalCtx env metadataDbUrl rci res <- runTxWithMinimalPool _gcMetadataDbConnInfo fetchMetadataFromCatalog either (throwErrJExit MetadataExportError) printJSON res HCClean -> do + GlobalCtx {..} <- initGlobalCtx env metadataDbUrl rci res <- runTxWithMinimalPool _gcMetadataDbConnInfo dropHdbCatalogSchema let cleanSuccessMsg = "successfully cleaned graphql-engine related data" either (throwErrJExit MetadataCleanError) (const $ liftIO $ putStrLn cleanSuccessMsg) res HCDowngrade opts -> do + GlobalCtx {..} <- initGlobalCtx env metadataDbUrl rci + let (maybeDefaultPgConnInfo, maybeRetries) = _gcDefaultPostgresConnInfo let defaultSourceConfig = maybeDefaultPgConnInfo <&> \(dbUrlConf, _) -> let pgSourceConnInfo =