41 if (!
$DIC->settings()->get(
'soap_user_administration')) {
42 $DIC->logger()->bgtk()->warning(
"SOAP not enabled, fallback to sync version");
44 $sync_manager->run($bucket);
50 $DIC->backgroundTasks()->persistence()->saveBucketAndItsTasks($bucket);
52 $DIC->logger()->bgtk()->info(
"Trying to call webserver");
55 $soap_client = new \ilSoapClient();
56 $soap_client->setResponseTimeout(1);
57 $soap_client->enableWSDL(
true);
59 $session_id = session_id();
62 $DIC->refinery()->byTrying([
63 $DIC->refinery()->kindlyTo()->string(),
64 $DIC->refinery()->always(
71 $soap_client->call(self::CMD_START_WORKER, [
74 }
catch (\Throwable $t) {
75 $DIC->logger()->bgtk()->warning($t->getMessage());
76 $DIC->logger()->bgtk()->warning(
"Calling webserver failed, fallback to sync version");
78 $sync_manager->run($bucket);
81 $DIC->logger()->bgtk()->info(
"Calling webserver successful");
91 $n_of_tasks =
$ilIliasIniFile->readVariable(
"background_tasks",
"number_of_concurrent_tasks");
92 $n_of_tasks = $n_of_tasks ?: 5;
94 $DIC->logger()->bgtk()->info(
"Starting background job.");
95 $persistence =
$DIC->backgroundTasks()->persistence();
98 $MAX_PARALLEL_JOBS = $n_of_tasks;
99 if (count($persistence->getBucketIdsByState(
State::RUNNING)) >= $MAX_PARALLEL_JOBS) {
100 $DIC->logger()->bgtk()->info(
"Too many running jobs, worker going down.");
114 $bucket_id = (
int) array_shift($ids);
116 $bucket = $persistence->loadBucket($bucket_id);
119 $DIC->logger()->bgtk()->info(
120 "Bucket with id $bucket_id no longer exists, skipping it."
126 $DIC->logger()->bgtk()->warning(
127 "Could not load bucket with id $bucket_id, skipping and deleting it: " .
$e->getMessage()
130 $persistence->deleteBucketById($bucket_id);
131 }
catch (\Throwable $t) {
132 $DIC->logger()->bgtk()->error(
133 "Could not delete bucket with id $bucket_id, worker going down: " . $t->getMessage()
138 }
catch (\Throwable $t) {
140 $DIC->logger()->bgtk()->error(
141 "Could not load bucket with id $bucket_id, worker going down: " . $t->getMessage()
148 $task = $bucket->getTask();
153 $this->persistence->updateBucket($bucket);
156 $this->persistence->deleteBucket($bucket);
159 $this->persistence->saveBucketAndItsTasks($bucket);
160 }
catch (\Throwable
$e) {
161 $persistence->deleteBucket($bucket);
162 $DIC->logger()->bgtk()->info(
"Exception while async computing: "
164 $DIC->logger()->bgtk()->info(
"Stack Trace: "
165 .
$e->getTraceAsString());
169 $DIC->logger()->bgtk()->info(
"One worker going down because there's nothing left to do.");
run(Bucket $bucket)
This will add an Observer of the Task and start running the task.
Class PersistingObserver.
setCurrentTask(Task $task)
executeTask(Task $task, Observer $observer)
Actually executes a task.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...