Use LockRestart in Main.hs
src/Main.hs
Mon Jun 9 22:36:12 CEST 2008 Joachim Breitner <mail@joachim-breitner.de>
* Use LockRestart in Main.hs
--- old-darcswatch/src/Main.hs 2014-09-03 08:55:41.260052694 +0200
+++ new-darcswatch/src/Main.hs 2014-09-03 08:55:42.144036718 +0200
@@ -38,6 +38,7 @@
import Darcs
-- Web ouput
import HTML
+import LockRestart
import Data.Digest.OpenSSL.MD5 (md5sum)
@@ -56,6 +57,27 @@
_ -> error "Use darcswatch confdir/"
putStrLn "Reading configuration..."
config <- read `fmap` readFile (confdir ++ "config")
+
+ putStrLn "Trying to get lock..."
+ l <- lockOrMark (cOutput config) patchNew
+ if l then do
+ putStrLn "Got the lock, going to work..."
+ do_work config patchNew
+ checkAndWork config
+ else
+ putStrLn "Could not get locked, signaled restart"
+
+checkAndWork config = do
+ putStrLn "Trying to release the lock..."
+ msgs <- releaseLock (cOutput config)
+ if null msgs then do
+ putStrLn "Successfully released lock."
+ else do
+ putStrLn "New work to do..."
+ do_work config (or msgs)
+ checkAndWork config
+
+do_work config patchNew = do
putStrLn "Reading repositories..."
let readInv (p2r,r2p,new) rep = do
putStrLn $ "Reading " ++ rep ++ " ..."