@startuml
start
:detach thread;
:set job status to JS_Running;

if (max start delay exceeded) then (yes)
  :cancel job; <<#tomato>>
  detach
endif
if (max run sched time exceeded) then (yes)
  :cancel job; <<#tomato>>
  detach
endif
:UpdateJobStartRecord(); <<procedure>>
:RunScripts(BeforeJob); <<procedure>>
:UpdateJobStartRecord(); <<procedure>>
note
  this happens twice so files created
  by a runscript are not picked up
  twice
end note
:GeneratePluginEvent(bDirEventJobRun); <<procedure>>

partition "Job-Type specific run" {
  :this is where the actual job run happens;
}

:warn if subscriptions exceeded;

:RunScripts(AfterJob); <<procedure>>
:DequeueMessages(); <<procedure>>
:GeneratePluginEvent(bDirEventJobEnd); <<procedure>>
end
@enduml
