Skip to content

Commit

Permalink
Merge pull request #9690 from jonasraoni/bugfix/main/9682-decouple-sc…
Browse files Browse the repository at this point in the history
…heduled-tasks-from-jobs

#9682 Decoupled the execution of scheduled tasks to the ex…
  • Loading branch information
jonasraoni authored Feb 5, 2024
2 parents 2d98998 + 1bf49d7 commit 369166c
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions classes/task/ProcessQueueJobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getName()
*/
public function executeActions()
{
if (Application::isUnderMaintenance()) {
if (Application::isUnderMaintenance() || !Config::getVar('queues', 'job_runner', true)) {
return true;
}

Expand All @@ -49,7 +49,7 @@ public function executeActions()
return true;
}

// Run queue jobs on CLI
// Executes all pending jobs when running the runScheduledTasks.php on the CLI
if (runOnCLI('runScheduledTasks.php')) {
while ($jobBuilder->count()) {
$jobQueue->runJobInQueue();
Expand All @@ -58,15 +58,13 @@ public function executeActions()
return true;
}

// Run queue jobs off CLI
if (Config::getVar('queues', 'job_runner', false)) {
(new JobRunner($jobQueue))
->withMaxExecutionTimeConstrain()
->withMaxJobsConstrain()
->withMaxMemoryConstrain()
->withEstimatedTimeToProcessNextJobConstrain()
->processJobs($jobBuilder);
}
// Executes a limited number of jobs when processing a request
(new JobRunner($jobQueue))
->withMaxExecutionTimeConstrain()
->withMaxJobsConstrain()
->withMaxMemoryConstrain()
->withEstimatedTimeToProcessNextJobConstrain()
->processJobs($jobBuilder);

return true;
}
Expand Down

0 comments on commit 369166c

Please sign in to comment.