Commit 04715f2b authored by Mart Lubbers's avatar Mart Lubbers

print exception when there are only startup tasks

parent d0414ba4
Pipeline #23068 passed with stage
in 5 minutes and 46 seconds
......@@ -56,14 +56,15 @@ where
webTasks = [t \\ WebTask t <- toStartable startable]
startupTasks {distributed, sdsPort}
//If distributed, start sds service task
= (if distributed [startTask (sdsServiceTask sdsPort)] [])
++ [startTask flushWritesWhenIdle
= (if distributed [systemTask (startTask (sdsServiceTask sdsPort))] [])
++ [systemTask (startTask flushWritesWhenIdle)
//If there no webtasks, stop when stable, otherwise cleanup old sessions
,startTask if (webTasks =: []) stopOnStable removeOutdatedSessions
,systemTask (startTask if (webTasks =: []) stopOnStable removeOutdatedSessions)
//Start all startup tasks
:[t \\ StartupTask t <- toStartable startable]]
startTask t = {StartupTask|attributes=defaultValue,task=TaskWrapper t}
systemTask t = {StartupTask|t&attributes='DM'.put "system" "yes" t.StartupTask.attributes}
initSymbolsShare False _ iworld = (Ok (), iworld)
initSymbolsShare True appName iworld = case storeSymbols (IF_WINDOWS (appName +++ ".exe") appName) iworld of
......
......@@ -12,8 +12,9 @@ import iTasks.Internal.TaskStore
import iTasks.SDS.Combinators.Common
import iTasks.UI.Definition
import iTasks.WF.Definition
import Text
from Data.Map import newMap
from Data.Map import newMap, member
everyTick :: (*IWorld -> *(!MaybeError TaskException (), !*IWorld)) -> Task ()
everyTick f = Task eval
......@@ -82,16 +83,24 @@ flushWritesWhenIdle = everyTick \iworld->case read taskEvents EmptyContext iworl
//When we don't run the built-in HTTP server we don't want to loop forever so we stop the loop
//once all tasks are stable
stopOnStable :: Task ()
stopOnStable = everyTick \iworld=:{IWorld|shutdown}->case read (sdsFocus {InstanceFilter|defaultValue & includeProgress=True} filteredInstanceIndex) EmptyContext iworld of
stopOnStable = everyTick \iworld->case read (sdsFocus {InstanceFilter|defaultValue & includeProgress=True, includeStartup=True, includeAttributes=True} filteredInstanceIndex) EmptyContext iworld of
(Ok (ReadingDone index), iworld)
# shutdown = case shutdown of
Nothing = if (allStable index) (Just (if (exceptionOccurred index) 1 0)) Nothing
_ = shutdown
= (Ok (), {IWorld|iworld & shutdown = shutdown})
# iworld = case exceptions index of
[] = iworld
excs
# (_, world) = fclose (stderr <<< join "\n" excs <<< "\n") iworld.world
= {IWorld | iworld & world=world, shutdown=Just 1}
# iworld = if (isNothing iworld.shutdown && all isStable index)
{IWorld | iworld & shutdown=Just 0}
iworld
= (Ok (), iworld)
(Ok _,iworld)
= (Error (exception "Unexpeced SDS state"),iworld)
(Error e, iworld) = (Error e, iworld)
where
allStable instances = all (\v -> v =: Stable || v =: (Exception _)) (values instances)
exceptionOccurred instances = any (\v -> v =: (Exception _)) (values instances)
values instances = [value \\ (_,_,Just {InstanceProgress|value},_) <- instances]
isStable (_, _, Nothing, _) = False
isStable (_, _, Just {InstanceProgress|value}, attributes)
| member "system" (fromMaybe newMap attributes) = True
= value =: Stable
exceptions instances = [e\\(_, _, Just {InstanceProgress|value=Exception e}, _)<-instances]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment