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 Jun 7, 2021
1 parent dd55249 commit fa59e76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions classes/core/PKPContainer.inc.php
Expand Up @@ -97,6 +97,10 @@ function ($app) {
}
);

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

Facade::setFacadeApplication($this);
}

Expand Down
19 changes: 12 additions & 7 deletions classes/core/PKPQueueProvider.inc.php
Expand Up @@ -24,14 +24,8 @@

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

if (!$shouldRun) {
return;
}

$job = PKPJobModel
::isavailable()
->notexcedeedattempts()
Expand Down Expand Up @@ -60,6 +54,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 fa59e76

Please sign in to comment.