aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kierán Meinhardt <kmein@posteo.de>2024-10-11 15:36:17 +0200
committerLibravatar Kierán Meinhardt <kmein@posteo.de>2024-10-11 15:37:09 +0200
commit309250b6a13cb4bcc6ca244506e75a6b76b78dc8 (patch)
treea73e381e6819e1f3e0a9dcd401f6e18543b533dc
parent0ce439dbfbbd8950a0d3129fc903eed9a9c73827 (diff)
log which path the backend serves, and where
-rw-r--r--backend/app/Main.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/backend/app/Main.hs b/backend/app/Main.hs
index 38ad1f1..282ef6c 100644
--- a/backend/app/Main.hs
+++ b/backend/app/Main.hs
@@ -29,7 +29,7 @@ import Options.Applicative qualified as A
import Route qualified as R
import Safe
import Store qualified as Q
-import System.Directory (setCurrentDirectory, doesDirectoryExist)
+import System.Directory (setCurrentDirectory, doesDirectoryExist, makeAbsolute)
import System.Exit
import System.FilePath
import System.INotify
@@ -205,16 +205,21 @@ main :: IO ()
main = do
A.execParser (A.info (args <**> A.helper) A.idm) >>= \case
Args {cmd = Serve {contentRepositoryPath, serverPort}} -> do
- contentRepositoryPathExists <- doesDirectoryExist (contentRepositoryPath </> ".git")
+ contentRepositoryPath' <- makeAbsolute contentRepositoryPath
+ contentRepositoryPathExists <- doesDirectoryExist (contentRepositoryPath' </> ".git")
+
unless contentRepositoryPathExists $ do
logStderr $ "Content repository '" ++ contentRepositoryPath ++ "' is not a git repository."
exitFailure
- setCurrentDirectory contentRepositoryPath
+
+ setCurrentDirectory contentRepositoryPath'
let root = "."
ref = "refs/heads/master"
repoT <- newEmptyTMVarIO
_ <- forkIO do watch repoT root ref
+ logStderr ("Serving " ++ contentRepositoryPath' ++ " on port " ++ show serverPort ++ ".")
+
W.runEnv serverPort $ \req respond -> do
case P.parseOnly R.parser (W.rawPathInfo req) of
Right (R.SchemaJson path) -> do