diff options
author | Joey Hess <joey@kitenet.net> | 2013-02-06 15:38:41 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-02-06 15:38:41 -0400 |
commit | 5d4a987bb9d0796af6597c307739482a4a8e1898 (patch) | |
tree | 5467d2d3f24132ed637a015b205003837211412a /Assistant | |
parent | eadcb2d93f5ed2ec280efede40c623c7a5394678 (diff) |
fix build with webapp disabled
Broken by recent thread manager and restarting improvements.
Diffstat (limited to 'Assistant')
-rw-r--r-- | Assistant/NamedThread.hs | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/Assistant/NamedThread.hs b/Assistant/NamedThread.hs index fd710cf54..0a090d0d2 100644 --- a/Assistant/NamedThread.hs +++ b/Assistant/NamedThread.hs @@ -5,6 +5,8 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Assistant.NamedThread where import Common.Annex @@ -12,23 +14,31 @@ import Assistant.Types.NamedThread import Assistant.Types.ThreadName import Assistant.Types.DaemonStatus import Assistant.DaemonStatus -import Assistant.Alert import Assistant.Monad -import Assistant.WebApp -import Assistant.WebApp.Types import Control.Concurrent import Control.Concurrent.Async import qualified Data.Map as M -import qualified Data.Text as T import qualified Control.Exception as E +#ifdef WITH_WEBAPP +import Assistant.WebApp +import Assistant.WebApp.Types +import Assistant.Alert +import qualified Data.Text as T +#endif + {- Starts a named thread, if it's not already running. - - Named threads are run by a management thread, so if they crash - an alert is displayed, allowing the thread to be restarted. -} +#ifdef WITH_WEBAPP startNamedThread :: Maybe UrlRenderer -> NamedThread -> Assistant () startNamedThread urlrenderer namedthread@(NamedThread name a) = do +#else +startNamedThread :: Maybe Bool -> NamedThread -> Assistant () +startNamedThread urlrenderer namedthread@(NamedThread name a) = do +#endif m <- startedThreads <$> getDaemonStatus case M.lookup name m of Nothing -> start @@ -58,20 +68,22 @@ startNamedThread urlrenderer namedthread@(NamedThread name a) = do , "crashed:", show e ] hPutStrLn stderr msg - button <- runAssistant d mkbutton +#ifdef WITH_WEBAPP + button <- runAssistant d $ + case urlrenderer of + Nothing -> return Nothing + Just renderer -> do + close <- asIO1 removeAlert + url <- liftIO $ renderUrl renderer (RestartThreadR name) [] + return $ Just $ AlertButton + { buttonLabel = T.pack "Restart Thread" + , buttonUrl = url + , buttonAction = Just close + } runAssistant d $ void $ addAlert $ (warningAlert (fromThreadName name) msg) { alertButton = button } - mkbutton = case urlrenderer of - Nothing -> return Nothing - Just renderer -> do - close <- asIO1 removeAlert - url <- liftIO $ renderUrl renderer (RestartThreadR name) [] - return $ Just $ AlertButton - { buttonLabel = T.pack "Restart Thread" - , buttonUrl = url - , buttonAction = Just close - } +#endif namedThreadId :: NamedThread -> Assistant (Maybe ThreadId) namedThreadId (NamedThread name _) = do |