feat: update maintenance task
This commit is contained in:
parent
c3205b8266
commit
47b206c445
2 changed files with 17 additions and 8 deletions
|
@ -20,10 +20,6 @@ use Utopia\Database\Query;
|
|||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Registry\Registry;
|
||||
use Appwrite\Utopia\Request;
|
||||
use Utopia\Cache\Adapter\Redis as RedisCache;
|
||||
use Utopia\Cache\Cache;
|
||||
use Utopia\Database\Adapter\MariaDB;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\WebSocket\Server;
|
||||
use Utopia\WebSocket\Adapter;
|
||||
|
||||
|
@ -101,13 +97,19 @@ function getDatabase(Registry &$register, string $projectId)
|
|||
/** Get the console DB */
|
||||
$database = $dbPool->getConsoleDB();
|
||||
$pdo = $dbPool->getPDOFromPool($database);
|
||||
$database = DatabasePool::getDatabase($pdo->getConnection(), $redis, '_console');
|
||||
$database = DatabasePool::wait(
|
||||
DatabasePool::getDatabase($pdo->getConnection(), $redis, '_console'),
|
||||
'realtime'
|
||||
);
|
||||
|
||||
if ($projectId !== 'console') {
|
||||
$project = Authorization::skip(fn() => $database->getDocument('projects', $projectId));
|
||||
$database = $project->getAttribute('database', '');
|
||||
$pdo = $dbPool->getPDOFromPool($database);
|
||||
$database = DatabasePool::getDatabase($pdo->getConnection(), $redis, "_{$project->getInternalId()}");
|
||||
$database = DatabasePool::wait(
|
||||
DatabasePool::getDatabase($pdo->getConnection(), $redis, "_{$project->getInternalId()}"),
|
||||
'realtime'
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
global $cli;
|
||||
global $register;
|
||||
|
||||
use Appwrite\Auth\Auth;
|
||||
use Appwrite\Database\DatabasePool;
|
||||
use Appwrite\Event\Certificate;
|
||||
use Appwrite\Event\Delete;
|
||||
use Utopia\App;
|
||||
|
@ -104,7 +104,14 @@ $cli
|
|||
|
||||
Console::loop(function () use ($register, $interval, $executionLogsRetention, $abuseLogsRetention, $auditLogRetention, $usageStatsRetention30m, $usageStatsRetention1d) {
|
||||
$redis = $register->get('cache');
|
||||
$database = $register->get('dbPool')->getDB('console', $redis);
|
||||
$dbPool = $register->get('dbPool');
|
||||
|
||||
$database = $dbPool->getConsoleDB();
|
||||
$pdo = $dbPool->getPDO($database);
|
||||
$database = DatabasePool::wait(
|
||||
DatabasePool::getDatabase($pdo, $redis, '_console'),
|
||||
'certificates',
|
||||
);
|
||||
|
||||
$time = date('d-m-Y H:i:s', time());
|
||||
Console::info("[{$time}] Notifying workers with maintenance tasks every {$interval} seconds");
|
||||
|
|
Loading…
Reference in a new issue