fix build with webapp disabled
Broken by recent thread manager and restarting improvements.
This commit is contained in:
parent
b1de99c1d4
commit
937cf81873
2 changed files with 31 additions and 17 deletions
|
@ -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
|
||||
|
|
|
@ -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,11 +68,9 @@ startNamedThread urlrenderer namedthread@(NamedThread name a) = do
|
|||
, "crashed:", show e
|
||||
]
|
||||
hPutStrLn stderr msg
|
||||
button <- runAssistant d mkbutton
|
||||
runAssistant d $ void $
|
||||
addAlert $ (warningAlert (fromThreadName name) msg)
|
||||
{ alertButton = button }
|
||||
mkbutton = case urlrenderer of
|
||||
#ifdef WITH_WEBAPP
|
||||
button <- runAssistant d $
|
||||
case urlrenderer of
|
||||
Nothing -> return Nothing
|
||||
Just renderer -> do
|
||||
close <- asIO1 removeAlert
|
||||
|
@ -72,6 +80,10 @@ startNamedThread urlrenderer namedthread@(NamedThread name a) = do
|
|||
, buttonUrl = url
|
||||
, buttonAction = Just close
|
||||
}
|
||||
runAssistant d $ void $
|
||||
addAlert $ (warningAlert (fromThreadName name) msg)
|
||||
{ alertButton = button }
|
||||
#endif
|
||||
|
||||
namedThreadId :: NamedThread -> Assistant (Maybe ThreadId)
|
||||
namedThreadId (NamedThread name _) = do
|
||||
|
|
Loading…
Reference in a new issue