Skip to content

Commit

Permalink
feat(TimedJob): Add debug log about time sensitive jobs with long int…
Browse files Browse the repository at this point in the history
…ervals

Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Oct 7, 2024
1 parent 7aa4549 commit 8d297e2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/public/BackgroundJob/TimedJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
namespace OCP\BackgroundJob;

use OCP\ILogger;
use OCP\Server;
use Psr\Log\LoggerInterface;

/**
* Simple base class to extend to run periodic background jobs.
Expand Down Expand Up @@ -80,6 +82,9 @@ final public function execute(IJobList $jobList, ?ILogger $logger = null) {
*/
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);
}
}
Expand Down

0 comments on commit 8d297e2

Please sign in to comment.