Skip to content

Commit

Permalink
pkp#9682 Decoupled the execution of scheduled tasks to the execution …
Browse files Browse the repository at this point in the history
…of jobs through a configuration
  • Loading branch information
jonasraoni authored and ipula committed Feb 22, 2024
1 parent 6b39372 commit 3c35376
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 3c35376

Please sign in to comment.