From 3c353761b86c3cda89a55ba0b64c7ca1e145381b Mon Sep 17 00:00:00 2001 From: Jonas Raoni Soares da Silva Date: Fri, 2 Feb 2024 22:52:19 +0300 Subject: [PATCH] pkp/pkp-lib#9682 Decoupled the execution of scheduled tasks to the execution of jobs through a configuration --- classes/task/ProcessQueueJobs.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/classes/task/ProcessQueueJobs.php b/classes/task/ProcessQueueJobs.php index 42e5b84aacf..9d8791b324b 100644 --- a/classes/task/ProcessQueueJobs.php +++ b/classes/task/ProcessQueueJobs.php @@ -37,7 +37,7 @@ public function getName() */ public function executeActions() { - if (Application::isUnderMaintenance()) { + if (Application::isUnderMaintenance() || !Config::getVar('queues', 'job_runner', true)) { return true; } @@ -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(); @@ -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; }