aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLia Lenckowski <lialenck@protonmail.com>2023-10-15 18:22:22 +0200
committerLia Lenckowski <lialenck@protonmail.com>2023-10-15 18:22:22 +0200
commitc575a2d9fe9eab97c6af7d20c577b6ea6a0e72aa (patch)
treef6adda550f346bf90baaba56153ffe5ff45f0b23
parent95149c9f252b4ee678b4d7b766c9c4830b548d07 (diff)
downloadfastbangs-c575a2d9fe9eab97c6af7d20c577b6ea6a0e72aa.tar
fastbangs-c575a2d9fe9eab97c6af7d20c577b6ea6a0e72aa.tar.bz2
fastbangs-c575a2d9fe9eab97c6af7d20c577b6ea6a0e72aa.tar.zst
revert dumme sachen die eh nicht vollständig waren
-rw-r--r--README.md1
-rw-r--r--src/Config.hs2
-rw-r--r--src/Main.hs25
3 files changed, 12 insertions, 16 deletions
diff --git a/README.md b/README.md
index b37e6b6..f2b1103 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,6 @@ If you go with environment variables, the following options are available:
- PORT: port to bind to. Default: 20546
- BIND\_ADDR: address to bind to. Default: any ipv4/ipv6 interface
- BASE\_URL: url of the deployed website, without trailing slash. Default: "http://localhost:20546"
-- DB\_PATH: path to the sqlite database used for storing bangs. Default: "banger.db"
- ADMIN\_USER: username for logging into the interface for accepting/rejecting bangs. Default: "bleb"
- ADMIN\_PW\_HASH: hash of the passwort used for logging in. Default: ""
- EMAIL\_CMD: path to an executable for sending emails. Will be called with the recipient, subject and body as command-line arguments. Default: ""
diff --git a/src/Config.hs b/src/Config.hs
index 137d42d..535f3e8 100644
--- a/src/Config.hs
+++ b/src/Config.hs
@@ -28,7 +28,6 @@ data Config = Config {
confHost :: HostPreference,
confBaseUrl :: Text,
confFavicon :: Text,
- confDbPath :: Text,
confUser :: Text,
confPwHash :: Text,
confEmailCmd :: Maybe FilePath,
@@ -46,7 +45,6 @@ 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 095cdbe..d69ced6 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -150,21 +150,20 @@ sendPendingBangs cfg pool = do
"Please do something about it.\n"
main :: IO ()
-main = do
- cfg <- getConfig
- runStdoutLoggingT $ withSqlitePool (confDbPath cfg) 2 $ \pool -> do
- runResourceT $ flip runSqlPool pool $ runMigration migrateAll
+main = runStdoutLoggingT $ withSqlitePool "banger.db" 2 $ \pool -> do
+ runResourceT $ flip runSqlPool pool $ runMigration migrateAll
- bs <- liftIO initBangState
- $(logInfo) $ "Using config: " <> T.pack (show cfg)
+ bs <- liftIO initBangState
+ cfg <- liftIO getConfig
+ $(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