summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-06 15:38:41 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-06 15:38:41 -0400
commit5d4a987bb9d0796af6597c307739482a4a8e1898 (patch)
tree5467d2d3f24132ed637a015b205003837211412a
parenteadcb2d93f5ed2ec280efede40c623c7a5394678 (diff)
fix build with webapp disabled
Broken by recent thread manager and restarting improvements.
-rw-r--r--Assistant.hs6
-rw-r--r--Assistant/NamedThread.hs42
2 files changed, 31 insertions, 17 deletions
diff --git a/Assistant.hs b/Assistant.hs
index 45c0e9f03..8a3816f4d 100644
--- a/Assistant.hs
+++ b/Assistant.hs
@@ -196,8 +196,10 @@ startDaemon assistant foreground startbrowser = do
#ifdef WITH_WEBAPP
d <- getAssistant id
urlrenderer <- liftIO newUrlRenderer
+ mapM_ (startthread $ Just urlrenderer)
+#else
+ mapM_ (startthread Nothing)
#endif
- mapM_ (startthread urlrenderer)
[ watch $ commitThread
#ifdef WITH_WEBAPP
, assist $ webAppThread d urlrenderer False Nothing webappwaiter
@@ -230,5 +232,5 @@ startDaemon assistant foreground startbrowser = do
watch a = (True, a)
assist a = (False, a)
startthread urlrenderer (watcher, t)
- | watcher || assistant = startNamedThread (Just urlrenderer) t
+ | watcher || assistant = startNamedThread urlrenderer t
| otherwise = noop
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