2012-09-06 14:56:04 -04:00
|
|
|
{- git-annex assistant daemon status thread
|
|
|
|
-
|
|
|
|
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- 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 02:21:04 -04:00
|
|
|
daemonStatusThread :: NamedThread
|
2013-01-26 17:09:33 +11:00
|
|
|
daemonStatusThread = namedThread "DaemonStatus" $ do
|
2013-03-27 14:56:15 -04:00
|
|
|
notifier <- liftIO . newNotificationHandle False
|
2012-10-30 14:44:18 -04:00
|
|
|
=<< changeNotifier <$> getDaemonStatus
|
2012-09-06 14:56:04 -04:00
|
|
|
checkpoint
|
2012-10-29 02:21:04 -04:00
|
|
|
runEvery (Seconds tenMinutes) <~> do
|
|
|
|
liftIO $ waitNotification notifier
|
2012-09-06 14:56:04 -04:00
|
|
|
checkpoint
|
2012-10-29 02:21:04 -04:00
|
|
|
where
|
|
|
|
checkpoint = do
|
|
|
|
file <- liftAnnex $ fromRepo gitAnnexDaemonStatusFile
|
2012-10-30 14:44:18 -04:00
|
|
|
liftIO . writeDaemonStatusFile file =<< getDaemonStatus
|