log which path the backend serves, and where

This commit is contained in:
2024-10-11 15:36:17 +02:00
parent 0ce439dbfb
commit 309250b6a1

View File

@@ -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