aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
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