From 309250b6a13cb4bcc6ca244506e75a6b76b78dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Fri, 11 Oct 2024 15:36:17 +0200 Subject: log which path the backend serves, and where --- backend/app/Main.hs | 11 ++++++++--- 1 file 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 -- cgit v1.2.3