on master help sign in
Run server in main thread
commitfdfbf3dd344318dbb4f104644c6b952e48df294c authorSimonas Kazlauskas <git@kazlauskas.me> dateSat 30 Mar 2013, 17:24 (14 years ago) parent42cdd64
2 files changed+4−12
src/Hakyll/Commands.hs+1−3 src/Hakyll/Preview/Poll.hs+3−9
src/Hakyll/Commands.hs+1−3
@@ -27,7 +27,6 @@ import Hakyll.Core.Util.File
2727
2828--------------------------------------------------------------------------------
2929#ifdef PREVIEW_SERVER
30−import Control.Concurrent (forkIO)
3130import qualified Data.Set as S
3231import Hakyll.Core.Identifier
3332import Hakyll.Core.Rules.Internal
@@ -68,9 +67,8 @@ clean conf = do
6867preview :: Configuration -> Verbosity -> Rules a -> Int -> IO ()
6968#ifdef PREVIEW_SERVER
7069preview conf verbosity rules port = do
71− -- Run the server in a separate thread
72− _ <- forkIO $ server conf port
7370 previewPoll conf update
71+ server conf port
7472 where
7573 update = do
7674 (exitCode, ruleSet) <- run conf verbosity rules
src/Hakyll/Preview/Poll.hs+3−9
@@ -3,12 +3,12 @@ module Hakyll.Preview.Poll
33 ) where
44
55--------------------------------------------------------------------------------
6−import Control.Concurrent (threadDelay)
76import Control.Monad (void)
87import Data.List (isPrefixOf)
98import Filesystem.Path.CurrentOS (decodeString, encodeString)
109import System.Directory (canonicalizePath)
11−import System.FSNotify (withManagerConf, watchTree, Event(..), WatchConfig(..))
10+import System.FSNotify (startManagerConf, watchTree,
11+ Event(..), WatchConfig(..))
1212import System.IO.Error (catchIOError)
1313
1414--------------------------------------------------------------------------------
@@ -21,7 +21,7 @@ import Hakyll.Core.Configuration
2121previewPoll :: Configuration -- ^ Configuration
2222 -> IO [FilePath] -- ^ Updating action
2323 -> IO () -- ^ Can block forever
24−previewPoll conf update = withManagerConf (Debounce 0.1) monitor
24+previewPoll conf update = monitor =<< startManagerConf (Debounce 0.1)
2525 where
2626 path = decodeString $ providerDirectory conf
2727 monitor manager = do
@@ -29,7 +29,6 @@ previewPoll conf update = withManagerConf (Debounce 0.1) monitor
2929 ignore <- mapM getPath
3030 [destinationDirectory, storeDirectory, tmpDirectory]
3131 watchTree manager path (predicate ignore) (\_ -> void update)
32− infiniteLoop
3332 getPath fn = catchIOError (canonicalizePath $ fn conf)
3433 (const $ return $ fn conf)
3534 predicate ignore evt
@@ -38,11 +37,6 @@ previewPoll conf update = withManagerConf (Debounce 0.1) monitor
3837 | (ignoreFile conf) (eventPath evt) == True = False
3938 | otherwise = True
4039
41−infiniteLoop :: IO ()
42−infiniteLoop = do
43− threadDelay maxBound
44− infiniteLoop
45−
4640eventPath :: Event -> FilePath
4741eventPath (Added p _) = encodeString p
4842eventPath (Modified p _) = encodeString p