2012-09-06 18:56:04 +00:00
|
|
|
{- git-annex assistant daemon status thread
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2012 Joey Hess <id@joeyh.name>
|
2012-09-06 18:56:04 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Assistant.Threads.DaemonStatus where
|
|
|
|
|
|
|
|
import Assistant.Common
|
|
|
|
import Assistant.DaemonStatus
|
|
|
|
import Utility.ThreadScheduler
|
|
|
|
import Utility.NotificationBroadcaster
|
|
|
|
|
|
|
|
{- This writes the daemon status to disk, when it changes, but no more
|
|
|
|
- frequently than once every ten minutes.
|
|
|
|
-}
|
2012-10-29 06:21:04 +00:00
|
|
|
daemonStatusThread :: NamedThread
|
2013-01-26 06:09:33 +00:00
|
|
|
daemonStatusThread = namedThread "DaemonStatus" $ do
|
2013-03-27 18:56:15 +00:00
|
|
|
notifier <- liftIO . newNotificationHandle False
|
2012-10-30 18:44:18 +00:00
|
|
|
=<< changeNotifier <$> getDaemonStatus
|
2012-09-06 18:56:04 +00:00
|
|
|
checkpoint
|
2012-10-29 06:21:04 +00:00
|
|
|
runEvery (Seconds tenMinutes) <~> do
|
|
|
|
liftIO $ waitNotification notifier
|
2012-09-06 18:56:04 +00:00
|
|
|
checkpoint
|
2012-10-29 06:21:04 +00:00
|
|
|
where
|
|
|
|
checkpoint = do
|
|
|
|
file <- liftAnnex $ fromRepo gitAnnexDaemonStatusFile
|
2012-10-30 18:44:18 +00:00
|
|
|
liftIO . writeDaemonStatusFile file =<< getDaemonStatus
|