1
0
Fork 0
mirror of synced 2024-06-03 03:14:50 +12:00

removed db instance, added time log

This commit is contained in:
Eldad Fux 2021-01-17 08:17:19 +02:00
parent 1da4fa8168
commit b719a030e0

View file

@ -4,23 +4,13 @@ global $cli;
require_once __DIR__.'/../init.php'; require_once __DIR__.'/../init.php';
use Appwrite\Database\Database;
use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
use Appwrite\Database\Adapter\Redis as RedisAdapter;
use Appwrite\Event\Event; use Appwrite\Event\Event;
use Utopia\App; use Utopia\App;
use Utopia\CLI\Console; use Utopia\CLI\Console;
use Utopia\Config\Config;
// TODO: Think of a better way to access consoleDB Console::title('Maintenance V1');
function getConsoleDB() {
global $register; Console::success(APP_NAME.' maintenance process v1 has started');
$consoleDB = new Database();
$consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register));
$consoleDB->setNamespace('app_console'); // Main DB
$consoleDB->setMocks(Config::getParam('collections', []));
return $consoleDB;
}
function notifyDeleteExecutionLogs() function notifyDeleteExecutionLogs()
{ {
@ -54,10 +44,9 @@ $cli
//Convert Seconds to microseconds //Convert Seconds to microseconds
$intervalMicroseconds = $interval * 1000000; $intervalMicroseconds = $interval * 1000000;
$consoleDB = getConsoleDB(); Console::loop(function() use ($interval){
$time = date('d-m-Y H:i:s', time());
Console::loop(function() use ($consoleDB, $interval){ Console::info("[{$time}] Notifying deletes workers every {$interval} seconds");
Console::info("[ MAINTENANCE TASK ] Notifying deletes workers every {$interval} seconds");
notifyDeleteExecutionLogs(); notifyDeleteExecutionLogs();
notifyDeleteAbuseLogs($interval); notifyDeleteAbuseLogs($interval);
notifyDeleteAuditLogs($interval); notifyDeleteAuditLogs($interval);