From 47b206c445b3fe98e33f57d1abbf6fb5d2ae6e7f Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 24 Aug 2022 21:58:04 +0530 Subject: [PATCH] feat: update maintenance task --- app/realtime.php | 14 ++++++++------ app/tasks/maintenance.php | 11 +++++++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/realtime.php b/app/realtime.php index b3dad83bff..ea7519e04b 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -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 [ diff --git a/app/tasks/maintenance.php b/app/tasks/maintenance.php index 94022596a6..68eaf3b5c7 100644 --- a/app/tasks/maintenance.php +++ b/app/tasks/maintenance.php @@ -1,9 +1,9 @@ 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");