Skip to content

Commit

Permalink
pkp#7105 Adding callable methods for queueing system to be used at to…
Browse files Browse the repository at this point in the history
…ols/runScheduledTasks
  • Loading branch information
henriqueramos committed Feb 17, 2022
1 parent 5d6f34f commit 314d253
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions classes/core/PKPContainer.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ function ($app) {
}
);

$this->singleton('pkpQueue', function ($app) {
return new PKPQueueProvider();
});

Facade::setFacadeApplication($this);
}

Expand Down
13 changes: 12 additions & 1 deletion classes/core/PKPQueueProvider.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

class PKPQueueProvider
{
public function runJobsAtShutdown(): void
public function runQueuedJobs(): void
{
$disableRun = Config::getVar('queues', 'disable_jobs_run_at_shutdown', false);

Expand Down Expand Up @@ -62,6 +62,17 @@ public function runJobsAtShutdown(): void
);
}

public function runJobsAtShutdown(): void
{
$shouldRun = Config::getVar('queues', 'run_jobs_at_shutdown', false);

if (!$shouldRun) {
return;
}

$this->runQueuedJobs();
}

public function register()
{
register_shutdown_function([$this, 'runJobsAtShutdown']);
Expand Down

0 comments on commit 314d253

Please sign in to comment.