diff options
Diffstat (limited to 'backend/app/Main.hs')
-rw-r--r-- | backend/app/Main.hs | 11 |
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 |