aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorstuebinm2024-07-05 22:56:52 +0200
committerstuebinm2024-07-05 22:58:16 +0200
commit2943327863bfe5c6e793e5c40e473a2755d45642 (patch)
treef3fe224fc47203d962319f4f9cc5a43d29346f9a /app
parentbf52f12fd1710df52abd104622ea63cf2c26ff59 (diff)
Config: switch conferer → conftrackHEADmain
conftrack is a configuration library that I wrote to replace conferer, as dealing with its idiosyncrasies became increasingly annoying. It is currently very much still alpha-state software, but far enough along to be tested in my own projects, and hopefully will soon be in a state that is publishable on hackage. For now, it can be found at https://stuebinm.eu/git/conftrack
Diffstat (limited to '')
-rw-r--r--app/Main.hs35
1 files changed, 16 insertions, 19 deletions
diff --git a/app/Main.hs b/app/Main.hs
index a61140a..3856a67 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -1,15 +1,15 @@
+{-# LANGUAGE OverloadedLists #-}
+{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RecordWildCards #-}
-- | The main module. Does little more than handle some basic ocnfic, then
-- call the server
module Main where
-import Conferer (fetch)
-import Conferer.Config (addSource, emptyConfig)
-import qualified Conferer.Source.Aeson as ConfAeson
-import qualified Conferer.Source.CLIArgs as ConfCLI
-import qualified Conferer.Source.Env as ConfEnv
-import qualified Conferer.Source.Yaml as ConfYaml
+import Conftrack
+import Conftrack.Pretty
+import Conftrack.Source.Env (mkEnvSource)
+import Conftrack.Source.Yaml (mkYamlFileSource)
import Control.Monad.Extra (ifM)
import Control.Monad.IO.Class (MonadIO (liftIO))
import Control.Monad.Logger (runStderrLoggingT)
@@ -20,6 +20,7 @@ import Network.Wai.Middleware.RequestLogger (OutputFormat (..),
RequestLoggerSettings (..),
mkRequestLogger)
import System.Directory (doesFileExist)
+import System.OsPath (osp)
import Config (ServerConfig (..))
import GTFS (loadGtfs)
@@ -27,19 +28,15 @@ import Server (application)
main :: IO ()
main = do
- confconfig <- pure emptyConfig
- >>= addSource ConfCLI.fromConfig
- >>= addSource (ConfEnv.fromConfig "tracktrain")
- -- for some reason the yaml source fails if the file does not exist, but json works fine
- >>= (\c -> ifM (doesFileExist "./config.yaml")
- (addSource (ConfYaml.fromFilePath "./config.yaml") c)
- (pure c))
- >>= (\c -> ifM (doesFileExist "./config.yml")
- (addSource (ConfYaml.fromFilePath "./config.yml") c)
- (pure c))
- >>= addSource (ConfAeson.fromFilePath "./config.json")
-
- settings@ServerConfig{..} <- fetch confconfig
+
+ Right ymlsource <- mkYamlFileSource [osp|./config.yaml|]
+
+ Right (settings@ServerConfig{..}, origins, warnings) <-
+ runFetchConfig [mkEnvSource "tracktrain", ymlsource]
+
+ putStrLn "reading configs .."
+ printConfigOrigins origins
+ printConfigWarnings warnings
gtfs <- loadGtfs serverConfigGtfs serverConfigZoneinfoPath
loggerMiddleware <- mkRequestLogger