Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2015-03-29 22:38:15 +0300
committerdiosmosis <benaka@piwik.pro>2015-04-01 04:37:28 +0300
commitb70727fb720098a63272870025879e7e395512dd (patch)
tree1e6a57ce496ea7182fbb897f95b391118ca9933a /core/Scheduler
parentf595087622b06707a67d761e07cf0147f0ace6b5 (diff)
Refs #7181, add logging to ArchivePurger service + archive purging scheduled tasks + Scheduler, modify CronArchive to run scheduled tasks within same process as core:archive so logs are visible in core:archive output.
Diffstat (limited to 'core/Scheduler')
-rw-r--r--core/Scheduler/Scheduler.php18
-rw-r--r--core/Scheduler/Timetable.php6
2 files changed, 19 insertions, 5 deletions
diff --git a/core/Scheduler/Scheduler.php b/core/Scheduler/Scheduler.php
index 7156e1be9c..f4e2097ca5 100644
--- a/core/Scheduler/Scheduler.php
+++ b/core/Scheduler/Scheduler.php
@@ -99,9 +99,9 @@ class Scheduler
// for every priority level, starting with the highest and concluding with the lowest
$executionResults = array();
- for ($priority = Task::HIGHEST_PRIORITY;
- $priority <= Task::LOWEST_PRIORITY;
- ++$priority) {
+ for ($priority = Task::HIGHEST_PRIORITY; $priority <= Task::LOWEST_PRIORITY; ++$priority) {
+ $this->logger->debug("Executing tasks with priority {priority}:", array('priority' => $priority));
+
// loop through each task
foreach ($tasks as $task) {
// if the task does not have the current priority level, don't execute it yet
@@ -113,14 +113,24 @@ class Scheduler
$shouldExecuteTask = $this->timetable->shouldExecuteTask($taskName);
if ($this->timetable->taskShouldBeRescheduled($taskName)) {
- $this->timetable->rescheduleTask($task);
+ $rescheduledDate = $this->timetable->rescheduleTask($task);
+
+ $this->logger->debug("Task {task} is scheduled to run again for {date}.", array('task' => $taskName, 'date' => $rescheduledDate));
}
if ($shouldExecuteTask) {
+ $this->logger->info("Scheduler: executing task {taskName}...", array('taskName' => $taskName));
+
+ $timer = new Timer();
+
$this->isRunningTask = true;
$message = $this->executeTask($task);
$this->isRunningTask = false;
+ $this->logger->info("Scheduler: finished executing task {taskName}. {timeElapsed}", array(
+ 'taskName' => $taskName, 'timeElapsed' => $timer
+ ));
+
$executionResults[] = array('task' => $taskName, 'output' => $message);
}
}
diff --git a/core/Scheduler/Timetable.php b/core/Scheduler/Timetable.php
index 5c9bc69696..c3c01ab167 100644
--- a/core/Scheduler/Timetable.php
+++ b/core/Scheduler/Timetable.php
@@ -105,9 +105,13 @@ class Timetable
public function rescheduleTask(Task $task)
{
+ $rescheduledTime = $task->getRescheduledTime();
+
// update the scheduled time
- $this->timetable[$task->getName()] = $task->getRescheduledTime();
+ $this->timetable[$task->getName()] = $rescheduledTime;
$this->save();
+
+ return Date::factory($rescheduledTime);
}
public function save()