]> source.dussan.org Git - nextcloud-server.git/commitdiff
feat(TimedJob): Add debug log about time sensitive jobs with long intervals fix/backgroundjobs/adjust-intervals-time-sensitivities 48600/head
authorprovokateurin <kate@provokateurin.de>
Mon, 7 Oct 2024 15:37:38 +0000 (17:37 +0200)
committerprovokateurin <kate@provokateurin.de>
Tue, 8 Oct 2024 09:26:53 +0000 (11:26 +0200)
Signed-off-by: provokateurin <kate@provokateurin.de>
lib/public/BackgroundJob/TimedJob.php

index 6a81e841460080dd5eaf41410182ea68e1455916..85ca34665b41cab28309cb4ee07aedd57bee1119 100644 (file)
@@ -8,6 +8,8 @@ declare(strict_types=1);
 namespace OCP\BackgroundJob;
 
 use OCP\ILogger;
+use OCP\Server;
+use Psr\Log\LoggerInterface;
 
 /**
  * Simple base class to extend to run periodic background jobs.
@@ -80,6 +82,9 @@ abstract class TimedJob extends Job {
         */
        final public function start(IJobList $jobList): void {
                if (($this->time->getTime() - $this->lastRun) > $this->interval) {
+                       if ($this->interval >= 12 * 60 * 60 && $this->isTimeSensitive()) {
+                               Server::get(LoggerInterface::class)->debug('TimedJob ' . get_class($this) . ' has a configured interval of ' . $this->interval . ' seconds, but is also marked as time sensitive. Please consider marking it as time insensitive to allow more sensitive jobs to run when needed.');
+                       }
                        parent::start($jobList);
                }
        }