ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCronEcsTaskScheduler.php
Go to the documentation of this file.
1<?php
2
21
29{
30 public const ID = 'ecs_task_handler';
31 public const DEFAULT_SCHEDULE_VALUE = 1;
32
36
37 public function __construct()
38 {
39 global $DIC;
40
41 $this->logger = $DIC->logger()->wsrv();
42 $this->lng = $DIC->language();
43 $this->lng->loadLanguageModule('ecs');
44
45 $this->result = new \ILIAS\Cron\Job\JobResult();
46 }
47
48 public function getTitle(): string
49 {
50 return $this->lng->txt('ecs_cron_task_scheduler');
51 }
52
53 public function getDescription(): string
54 {
55 return $this->lng->txt('ecs_cron_task_scheduler_info');
56 }
57
58 public function getId(): string
59 {
60 return self::ID;
61 }
62
63 public function hasAutoActivation(): bool
64 {
65 return false;
66 }
67
68 public function hasFlexibleSchedule(): bool
69 {
70 return true;
71 }
72
74 {
75 return JobScheduleType::IN_HOURS;
76 }
77
78 public function getDefaultScheduleValue(): ?int
79 {
81 }
82
83 public function run(): JobResult
84 {
85 $this->logger->debug('Starting ecs task scheduler...');
86
88
89 foreach ($servers->getServers(ilECSServerSettings::ACTIVE_SERVER) as $server) {
90 try {
91 $this->logger->info('Starting task execution for ecs server: ' . $server->getTitle());
92 $scheduler = \ilECSTaskScheduler::_getInstanceByServerId($server->getServerId());
93 $scheduler->startTaskExecution();
94 } catch (Exception $e) {
95 $this->result->setStatus(\ILIAS\Cron\Job\JobResult::STATUS_CRASHED);
96 $this->result->setMessage(
97 mb_substr(sprintf('Exc.: %s / %s', $e->getMessage(), $e->getTraceAsString()), 0, 400)
98 );
99 $this->logger->error('ECS task execution failed with message: ' . $e->getMessage());
100 $this->logger->error($e->getTraceAsString());
101 return $this->result;
102 }
103 }
104 $this->result->setStatus(\ILIAS\Cron\Job\JobResult::STATUS_OK);
105 return $this->result;
106 }
107}
setStatus(int $a_value)
Definition: JobResult.php:58
Class ilCronEcsTaskScheduler.
hasAutoActivation()
Is to be activated on "installation", does only work for ILIAS core cron jobs.
static getInstance()
Get singleton instance.
static _getInstanceByServerId($a_server_id)
get singleton instance Private access use ilECSTaskScheduler::start() or ilECSTaskScheduler::startTas...
language handling
Component logger with individual log levels by component id.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26
$server
Definition: shib_login.php:28