summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2014-03-05 11:21:55 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2014-03-05 11:21:55 +0100
commit677a7f0f2d6e2daeb57f7897b1f77b0993243839 (patch)
tree18eca7cf1f28dac10def8df6c4379ef61462db3b
parentecdc1d3efc2d333225da12d69ed0eed1cbbea5e2 (diff)
parent6521cd7cbcea170ab2b02ed690e8de196ec01eed (diff)
downloadhakyll-677a7f0f2d6e2daeb57f7897b1f77b0993243839.tar.gz
Merge pull request #230 from nagisa/watch-threading
Use OS threads for watch in Windows
-rw-r--r--src/Hakyll/Commands.hs21
-rw-r--r--web/tutorials/01-installation.markdown2
2 files changed, 15 insertions, 8 deletions
diff --git a/src/Hakyll/Commands.hs b/src/Hakyll/Commands.hs
index 7951f4e..6664181 100644
--- a/src/Hakyll/Commands.hs
+++ b/src/Hakyll/Commands.hs
@@ -9,13 +9,15 @@ module Hakyll.Commands
, rebuild
, server
, deploy
- , watch
+ , watch
) where
--------------------------------------------------------------------------------
import System.Exit (exitWith, ExitCode)
+import System.IO.Error (catchIOError)
import Control.Applicative
+import Control.Monad (void)
import Control.Concurrent
--------------------------------------------------------------------------------
@@ -83,17 +85,22 @@ preview _ _ _ _ = previewServerDisabled
watch :: Configuration -> Verbosity -> Int -> Bool -> Rules a -> IO ()
#ifdef WATCH_SERVER
watch conf verbosity port runServer rules = do
- watchUpdates conf update
- _ <- forkIO (server')
- loop
+#ifndef mingw32_HOST_OS
+ _ <- forkIO $ watchUpdates conf update
+#else
+ -- Force windows users to compile with -threaded flag, as otherwise
+ -- thread is blocked indefinitely.
+ catchIOError (void $ forkOS $ watchUpdates conf update) $ do
+ fail $ "Hakyll.Commands.watch: Could not start update watching " ++
+ "thread. Did you compile with -threaded flag?"
+#endif
+ server'
where
update = do
(_, ruleSet) <- run conf verbosity rules
return $ rulesPattern ruleSet
-
loop = threadDelay 100000 >> loop
-
- server' = if runServer then server conf port else return ()
+ server' = if runServer then server conf port else loop
#else
watch _ _ _ _ _ = watchServerDisabled
#endif
diff --git a/web/tutorials/01-installation.markdown b/web/tutorials/01-installation.markdown
index c02a86e..5421c73 100644
--- a/web/tutorials/01-installation.markdown
+++ b/web/tutorials/01-installation.markdown
@@ -49,7 +49,7 @@ The file `site.hs` holds the configuration of your site, as an executable
haskell program. We can compile and run it like this:
$ cd my-site
- $ ghc --make site.hs
+ $ ghc --make -threaded site.hs
$ ./site build
If you installed `hakyll` with a preview server (this is the default), you can