diff --git a/src/Roux/Server.hs b/src/Roux/Server.hs index 55ddb30..56fc54b 100644 --- a/src/Roux/Server.hs +++ b/src/Roux/Server.hs @@ -23,7 +23,7 @@ import Data.Text (Text) import Data.Time.Clock (UTCTime, diffUTCTime, getCurrentTime) import qualified Network.HTTP.Types as HTTP import qualified Network.Wai as Wai -import System.Directory (doesFileExist) +import System.Directory (doesFileExist, makeAbsolute) import System.FSNotify ( Event (..), EventIsDirectory (..), @@ -56,10 +56,12 @@ app recipeDir = do -- Build initial map keyed by lowercased filename (without .cook extension) let recipeMap = Map.fromList [(map toLower (stripCookExt (Idx.riFilename r)), r) | r <- recipes] state <- newIORef recipeMap + -- Resolve to absolute path so makeRelative works with fsnotify events + absDir <- makeAbsolute recipeDir -- Start the filesystem watcher _ <- forkIO $ - watchRecipes recipeDir state `catch` \e -> + watchRecipes absDir state `catch` \e -> putStrLn $ "[roux] watcher thread crashed: " <> show (e :: SomeException) pure (handleRequest state) where