aboutsummaryrefslogtreecommitdiffstats
path: root/cron.php
diff options
context:
space:
mode:
authorJulien Veyssier <julien-nc@posteo.net>2024-04-08 17:25:51 +0200
committerJulien Veyssier <julien-nc@posteo.net>2024-05-02 16:43:41 +0200
commit1acc57b5c03b80ad5b6b5df7aff9df0fef83f14f (patch)
treeb8f0eaf7fca5bc99574a0f5a61ed24871aa90372 /cron.php
parenta5f244a58b6cfcc4feb8d8bdf33b40f983c342cb (diff)
downloadnextcloud-server-1acc57b5c03b80ad5b6b5df7aff9df0fef83f14f.tar.gz
nextcloud-server-1acc57b5c03b80ad5b6b5df7aff9df0fef83f14f.zip
feat(bg-jobs): allow setting a job class list instead of a single class in cron.php and the job worker occ command
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Diffstat (limited to 'cron.php')
-rw-r--r--cron.php18
1 files changed, 13 insertions, 5 deletions
diff --git a/cron.php b/cron.php
index dc2d821fc57..d0a8b770dfc 100644
--- a/cron.php
+++ b/cron.php
@@ -62,10 +62,10 @@ try {
Run the background job routine
Usage:
- php -f cron.php -- [-h] [<job-class>]
+ php -f cron.php -- [-h] [<job-classes>]
Arguments:
- job-class Optional job class to only run those jobs
+ job-classes Optional job class comma-separated list to only run those jobs
Options:
-h, --help Display this help message' . PHP_EOL;
@@ -175,9 +175,17 @@ Options:
$endTime = time() + 14 * 60;
$executedJobs = [];
- // a specific job class can optionally be given as first argument
- $jobClass = isset($argv[1]) ? $argv[1] : null;
- while ($job = $jobList->getNext($onlyTimeSensitive, $jobClass)) {
+ // a specific job class list can optionally be given as first argument
+ // only keep non-empty strings
+ $jobClasses = isset($argv[1])
+ ? array_filter(
+ explode(',', $argv[1]),
+ static function (string $jobClass) {
+ return strlen($jobClass) > 0;
+ }
+ )
+ : null;
+ while ($job = $jobList->getNext($onlyTimeSensitive, $jobClasses)) {
if (isset($executedJobs[$job->getId()])) {
$jobList->unlockJob($job);
break;