Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(TimedJob): Add debug log about time sensitive jobs with long int…
…ervals

Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Nov 25, 2024
commit 9388c96a31644f1347c682bc2e3e06a63fa202c2
5 changes: 5 additions & 0 deletions lib/public/BackgroundJob/TimedJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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 @@ -99,6 +101,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