This commit is contained in:
Joey Hess 2012-06-28 20:01:03 -04:00
parent 39569e889a
commit 247099f628

View file

@ -87,21 +87,24 @@ startDaemon assistant foreground
pidfile <- fromRepo gitAnnexPidFile pidfile <- fromRepo gitAnnexPidFile
go $ Utility.Daemon.daemonize logfd (Just pidfile) False go $ Utility.Daemon.daemonize logfd (Just pidfile) False
where where
go a = withThreadState $ \st -> do go daemonize = withThreadState $ \st -> do
checkCanWatch checkCanWatch
dstatus <- startDaemonStatus dstatus <- startDaemonStatus
liftIO $ a $ do liftIO $ daemonize $ run dstatus st
changechan <- newChangeChan run dstatus st = do
commitchan <- newCommitChan changechan <- newChangeChan
pushmap <- newFailedPushMap commitchan <- newCommitChan
_ <- forkIO $ commitThread st changechan commitchan pushmap <- newFailedPushMap
_ <- forkIO $ pushThread st commitchan pushmap mapM_ (void . forkIO)
_ <- forkIO $ pushRetryThread st pushmap [ commitThread st changechan commitchan
_ <- forkIO $ mergeThread st , pushThread st commitchan pushmap
_ <- forkIO $ daemonStatusThread st dstatus , pushRetryThread st pushmap
_ <- forkIO $ sanityCheckerThread st dstatus changechan , mergeThread st
_ <- forkIO $ watchThread st dstatus changechan , daemonStatusThread st dstatus
waitForTermination , sanityCheckerThread st dstatus changechan
, watchThread st dstatus changechan
]
waitForTermination
stopDaemon :: Annex () stopDaemon :: Annex ()
stopDaemon = liftIO . Utility.Daemon.stopDaemon =<< fromRepo gitAnnexPidFile stopDaemon = liftIO . Utility.Daemon.stopDaemon =<< fromRepo gitAnnexPidFile