summaryrefslogtreecommitdiff
path: root/Assistant.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-06-28 20:01:03 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-06-28 20:01:03 -0400
commit247099f6282262cb72027aeeadce2e7bb8073eef (patch)
treeb3de75955ef41c975b8961e94a297802618a7c28 /Assistant.hs
parent39569e889a5cdef913cd3927ee0383eafac77190 (diff)
refactor
Diffstat (limited to 'Assistant.hs')
-rw-r--r--Assistant.hs29
1 files changed, 16 insertions, 13 deletions
diff --git a/Assistant.hs b/Assistant.hs
index 2a11741b4..a077cf10f 100644
--- a/Assistant.hs
+++ b/Assistant.hs
@@ -87,21 +87,24 @@ startDaemon assistant foreground
pidfile <- fromRepo gitAnnexPidFile
go $ Utility.Daemon.daemonize logfd (Just pidfile) False
where
- go a = withThreadState $ \st -> do
+ go daemonize = withThreadState $ \st -> do
checkCanWatch
dstatus <- startDaemonStatus
- liftIO $ a $ do
- changechan <- newChangeChan
- commitchan <- newCommitChan
- pushmap <- newFailedPushMap
- _ <- forkIO $ commitThread st changechan commitchan
- _ <- forkIO $ pushThread st commitchan pushmap
- _ <- forkIO $ pushRetryThread st pushmap
- _ <- forkIO $ mergeThread st
- _ <- forkIO $ daemonStatusThread st dstatus
- _ <- forkIO $ sanityCheckerThread st dstatus changechan
- _ <- forkIO $ watchThread st dstatus changechan
- waitForTermination
+ liftIO $ daemonize $ run dstatus st
+ run dstatus st = do
+ changechan <- newChangeChan
+ commitchan <- newCommitChan
+ pushmap <- newFailedPushMap
+ mapM_ (void . forkIO)
+ [ commitThread st changechan commitchan
+ , pushThread st commitchan pushmap
+ , pushRetryThread st pushmap
+ , mergeThread st
+ , daemonStatusThread st dstatus
+ , sanityCheckerThread st dstatus changechan
+ , watchThread st dstatus changechan
+ ]
+ waitForTermination
stopDaemon :: Annex ()
stopDaemon = liftIO . Utility.Daemon.stopDaemon =<< fromRepo gitAnnexPidFile