Commit 7d4804dd authored by Mart Lubbers's avatar Mart Lubbers

remove stopOnStable backgroundtask

parent 9d236b15
Pipeline #19940 passed with stage
in 4 minutes and 42 seconds
...@@ -67,11 +67,14 @@ where ...@@ -67,11 +67,14 @@ where
startupTasks {distributed, sdsPort} startupTasks {distributed, sdsPort}
//If distributed, start sds service task //If distributed, start sds service task
= (if distributed [startTask (sdsServiceTask sdsPort)] []) = (if distributed [startTask (sdsServiceTask sdsPort)] [])
//If there are webtasks, we need to clean up sessions
++ if hasWebTasks [startTask removeOutdatedSessions] []
++ [startTask flushWritesWhenIdle] ++ [startTask flushWritesWhenIdle]
++ (if hasWebTasks
//If there are webtasks, we need to clean up sessions
[startTask removeOutdatedSessions]
//If there are none, we need to stop when all tasks are stable
[startTask stopOnStable]
//Start all startup tasks //Start all startup tasks
++ [t \\ StartupTask t <- toStartable startable] )++ [t \\ StartupTask t <- toStartable startable]
startTask t = {StartupTask|attributes=defaultValue,task=TaskWrapper t} startTask t = {StartupTask|attributes=defaultValue,task=TaskWrapper t}
...@@ -88,12 +91,7 @@ where ...@@ -88,12 +91,7 @@ where
| otherwise | otherwise
= [(serverPort,httpServer serverPort keepaliveTime (engineWebService webTasks) taskOutput)] = [(serverPort,httpServer serverPort keepaliveTime (engineWebService webTasks) taskOutput)]
engineTasks = engineTasks = [BackgroundTask (processEvents MAX_EVENTS)]
[BackgroundTask (processEvents MAX_EVENTS)
:if (webTasks =: [])
[BackgroundTask stopOnStable]
[]
]
// The iTasks engine consist of a set of HTTP Web services // The iTasks engine consist of a set of HTTP Web services
engineWebService :: [WebTask] -> [WebService (Map InstanceNo TaskOutput) (Map InstanceNo TaskOutput)] engineWebService :: [WebTask] -> [WebService (Map InstanceNo TaskOutput) (Map InstanceNo TaskOutput)]
......
...@@ -16,4 +16,4 @@ removeOutdatedSessions :: Task () ...@@ -16,4 +16,4 @@ removeOutdatedSessions :: Task ()
flushWritesWhenIdle:: Task () flushWritesWhenIdle:: Task ()
stopOnStable :: !*IWorld -> *(!MaybeError TaskException (), !*IWorld) stopOnStable :: Task ()
...@@ -123,16 +123,14 @@ flushWritesWhenIdle = everyTick \iworld->case read taskEvents EmptyContext iworl ...@@ -123,16 +123,14 @@ 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 //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 //once all tasks are stable
stopOnStable :: !*IWorld -> *(!MaybeError TaskException (), !*IWorld) stopOnStable :: Task ()
stopOnStable iworld=:{IWorld|shutdown} stopOnStable = everyTick \iworld=:{IWorld|shutdown}->case read (sdsFocus {InstanceFilter|defaultValue & includeProgress=True} filteredInstanceIndex) EmptyContext iworld of
# (mbIndex,iworld) = read (sdsFocus {InstanceFilter|defaultValue & includeProgress=True} filteredInstanceIndex) EmptyContext iworld (Ok (ReadingDone index), iworld)
= case mbIndex of
Ok (ReadingDone index)
# shutdown = case shutdown of # shutdown = case shutdown of
Nothing = if (allStable index) (Just (if (exceptionOccurred index) 1 0)) Nothing Nothing = if (allStable index) (Just (if (exceptionOccurred index) 1 0)) Nothing
_ = shutdown _ = shutdown
= (Ok (), {IWorld|iworld & shutdown = shutdown}) = (Ok (), {IWorld|iworld & shutdown = shutdown})
Error e = (Error e, iworld) (Error e, iworld) = (Error e, iworld)
where where
allStable instances = all (\v -> v =: Stable || v =: (Exception _)) (values instances) allStable instances = all (\v -> v =: Stable || v =: (Exception _)) (values instances)
exceptionOccurred instances = any (\v -> v =: (Exception _)) (values instances) exceptionOccurred instances = any (\v -> v =: (Exception _)) (values 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