aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Config.hs2
-rw-r--r--src/Main.hs25
2 files changed, 15 insertions, 12 deletions
diff --git a/src/Config.hs b/src/Config.hs
index 6ffb1fd..12fc09d 100644
--- a/src/Config.hs
+++ b/src/Config.hs
@@ -28,6 +28,7 @@ data Config = Config {
confHost :: HostPreference,
confBaseUrl :: Text,
confFavicon :: Text,
+ confDbPath :: Text,
confUser :: Text,
confPwHash :: Text,
confEmailCmd :: Maybe FilePath,
@@ -45,6 +46,7 @@ getConfig = do
<*> resolveVal (lookup "bind-addr" confFile) "BIND_ADDR" "*6"
<*> resolveVal (lookup "base-url" confFile) "BASE_URL" "http://localhost:20546"
<*> resolveVal (lookup "favicon-url" confFile) "FAVICON_URL" ""
+ <*> resolveVal (lookup "db-path" confFile) "DB_PATH" "banger.db"
<*> resolveVal (lookup "admin-user" confFile) "ADMIN_USER" "bleb"
<*> resolveVal (lookup "admin-pw-hash" confFile) "ADMIN_PW_HASH" "" -- prevent login without manual pw
<*> fmap (<|> lookup "email-command" confFile) (lookupEnv "EMAIL_CMD")
diff --git a/src/Main.hs b/src/Main.hs
index d69ced6..095cdbe 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -150,20 +150,21 @@ sendPendingBangs cfg pool = do
"Please do something about it.\n"
main :: IO ()
-main = runStdoutLoggingT $ withSqlitePool "banger.db" 2 $ \pool -> do
- runResourceT $ flip runSqlPool pool $ runMigration migrateAll
+main = do
+ cfg <- getConfig
+ runStdoutLoggingT $ withSqlitePool (confDbPath cfg) 2 $ \pool -> do
+ runResourceT $ flip runSqlPool pool $ runMigration migrateAll
- bs <- liftIO initBangState
- cfg <- liftIO getConfig
- $(logInfo) $ "Using config: " <> T.pack (show cfg)
+ bs <- liftIO initBangState
+ $(logInfo) $ "Using config: " <> T.pack (show cfg)
- sendPbIO <- toIO $ sendPendingBangs cfg pool
- notifyPb <- liftIO $ makeRunner sendPbIO 600000000 {- 10 min -}
+ sendPbIO <- toIO $ sendPendingBangs cfg pool
+ notifyPb <- liftIO $ makeRunner sendPbIO 600000000 {- 10 min -}
- sApp <- liftIO $ toWaiApp $ Search bs pool cfg notifyPb -- includes middlewares
+ sApp <- liftIO $ toWaiApp $ Search bs pool cfg notifyPb -- includes middlewares
- let settings = defaultSettings
- & setHost (confHost cfg)
- & setPort (confPort cfg)
+ let settings = defaultSettings
+ & setHost (confHost cfg)
+ & setPort (confPort cfg)
- liftIO $ runSettings settings sApp
+ liftIO $ runSettings settings sApp