<?php
/**
- * @file src/Core/Worker.php
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
*/
+
namespace Friendica\Core;
use Friendica\Core;
use Friendica\Util\Network;
/**
- * @file src/Core/Worker.php
- *
* Contains the class for the worker background job processing
*/
-
-/**
- * Worker methods
- */
class Worker
{
const STATE_STARTUP = 1; // Worker is in startup. This takes most time.
// Kill stale processes every 5 minutes
$last_cleanup = DI::config()->get('system', 'worker_last_cleaned', 0);
if (time() > ($last_cleanup + 300)) {
- Config::set('system', 'worker_last_cleaned', time());
+ DI::config()->set('system', 'worker_last_cleaned', time());
self::killStaleWorkers();
}
$stamp = (float)microtime(true);
$condition = ["`id` = ? AND `next_try` < ?", $queue['id'], DateTimeFormat::utcNow()];
if (DBA::update('workerqueue', ['done' => true], $condition)) {
- Config::set('system', 'last_worker_execution', DateTimeFormat::utcNow());
+ DI::config()->set('system', 'last_worker_execution', DateTimeFormat::utcNow());
}
self::$db_duration = (microtime(true) - $stamp);
self::$db_duration_write += (microtime(true) - $stamp);
$stamp = (float)microtime(true);
if (DBA::update('workerqueue', ['done' => true], ['id' => $queue["id"]])) {
- Config::set('system', 'last_worker_execution', DateTimeFormat::utcNow());
+ DI::config()->set('system', 'last_worker_execution', DateTimeFormat::utcNow());
}
self::$db_duration = (microtime(true) - $stamp);
self::$db_duration_write += (microtime(true) - $stamp);
return;
}
- Config::set("system", "worker_started", time());
+ DI::config()->set("system", "worker_started", time());
// Do we have enough running workers? Then we quit here.
if (self::tooMuchWorkers()) {