Group configuration by component ownership
This commit is contained in:
parent
48a5b8a433
commit
67cc0cb802
1 changed files with 486 additions and 258 deletions
34
app/Main.hs
34
app/Main.hs
|
|
@ -24,34 +24,40 @@ main :: IO ()
|
|||
main = do
|
||||
hSetBuffering stdout LineBuffering
|
||||
cfg <- loadConfig
|
||||
let runtimeCfg = cfgRuntime cfg
|
||||
httpCfg = cfgHttp cfg
|
||||
postgresCfg = cfgPostgres cfg
|
||||
redisCfg = cfgRedis cfg
|
||||
s3Cfg = cfgS3 cfg
|
||||
productCfg = cfgProduct cfg
|
||||
retryStartup
|
||||
(cfgStartupAttempts cfg)
|
||||
(cfgStartupDelayMs cfg)
|
||||
(cfgStartupAttempts runtimeCfg)
|
||||
(cfgStartupDelayMs runtimeCfg)
|
||||
"postgresql"
|
||||
(withDb cfg $ \db -> do
|
||||
(withDb postgresCfg $ \db -> do
|
||||
_ <- query_ db "SELECT 1" :: IO [Only Int]
|
||||
pure ())
|
||||
withDb cfg $ \db -> do
|
||||
withDb postgresCfg $ \db -> do
|
||||
schemaPath <- findSchema
|
||||
retryStartup
|
||||
(cfgStartupAttempts cfg)
|
||||
(cfgStartupDelayMs cfg)
|
||||
(cfgStartupAttempts runtimeCfg)
|
||||
(cfgStartupDelayMs runtimeCfg)
|
||||
"migration"
|
||||
(migrate db schemaPath cfg)
|
||||
withRedis cfg $ \redis -> do
|
||||
s3 <- newS3 cfg
|
||||
(migrate db schemaPath productCfg)
|
||||
withRedis redisCfg $ \redis -> do
|
||||
s3 <- newS3 s3Cfg
|
||||
let env = newEnv cfg db redis s3
|
||||
withLinkedWorker (runRecovery env) $ do
|
||||
let settings =
|
||||
setPort (cfgListenPort cfg) $
|
||||
setHost (readHost (cfgListenHost cfg)) defaultSettings
|
||||
setPort (cfgListenPort httpCfg) $
|
||||
setHost (readHost (cfgListenHost httpCfg)) defaultSettings
|
||||
putStrLn $
|
||||
"nuthatch listening on "
|
||||
<> cfgListenHost cfg
|
||||
<> cfgListenHost httpCfg
|
||||
<> ":"
|
||||
<> show (cfgListenPort cfg)
|
||||
<> show (cfgListenPort httpCfg)
|
||||
runTLS
|
||||
(tlsSettings (cfgTlsCertPath cfg) (cfgTlsKeyPath cfg))
|
||||
(tlsSettings (cfgTlsCertPath httpCfg) (cfgTlsKeyPath httpCfg))
|
||||
settings
|
||||
(application env)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue