diff --git a/app/cli.php b/app/cli.php index 413fa234ea..66c4208e14 100644 --- a/app/cli.php +++ b/app/cli.php @@ -13,4 +13,3 @@ $cliPlatform->init('CLI'); $cli = $cliPlatform->getCli(); $cli->run(); - diff --git a/src/Appwrite/Task/CLIPlatform.php b/src/Appwrite/Task/CLIPlatform.php index 847071fd63..063c6b6ca8 100644 --- a/src/Appwrite/Task/CLIPlatform.php +++ b/src/Appwrite/Task/CLIPlatform.php @@ -4,9 +4,10 @@ namespace Appwrite\Task; use Utopia\Platform\Platform; -class CLIPlatform extends Platform { +class CLIPlatform extends Platform +{ public function __construct() { $this->addService('cliTasks', new Tasks()); } -} \ No newline at end of file +} diff --git a/src/Appwrite/Task/Doctor.php b/src/Appwrite/Task/Doctor.php index 529116813b..281efe4d35 100644 --- a/src/Appwrite/Task/Doctor.php +++ b/src/Appwrite/Task/Doctor.php @@ -11,7 +11,8 @@ use Utopia\Storage\Storage; use Utopia\Domains\Domain; use Utopia\Platform\Action; -class Doctor extends Action{ +class Doctor extends Action +{ public const NAME = 'doctor'; public function __construct() @@ -252,4 +253,4 @@ class Doctor extends Action{ Console::error('Failed to check for a newer version' . "\n"); } } -} \ No newline at end of file +} diff --git a/src/Appwrite/Task/Install.php b/src/Appwrite/Task/Install.php index 8d6a7d4294..fe3fb826d4 100644 --- a/src/Appwrite/Task/Install.php +++ b/src/Appwrite/Task/Install.php @@ -1,4 +1,5 @@ get('db')), $cache); $database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); $database->setNamespace('_console'); // Main DB - + if (!$database->exists($database->getDefaultDatabase(), 'certificates')) { throw new \Exception('Console project not ready'); } - + break; // leave loop if successful } catch (\Exception $e) { Console::warning("Database not ready. Retrying connection ({$attempts})..."); @@ -44,10 +46,10 @@ class Maintenance extends Action { sleep(DATABASE_RECONNECT_SLEEP); } } while ($attempts < DATABASE_RECONNECT_MAX_ATTEMPTS); - + return $database; } - + public function __construct() { $this @@ -156,4 +158,4 @@ class Maintenance extends Action { renewCertificates($database); }, $interval); } -} \ No newline at end of file +} diff --git a/src/Appwrite/Task/Migrate.php b/src/Appwrite/Task/Migrate.php index 61cd757ca7..d1c154a0df 100644 --- a/src/Appwrite/Task/Migrate.php +++ b/src/Appwrite/Task/Migrate.php @@ -1,4 +1,5 @@ callback(fn ($version) => $this->action($version)); } - public function action($version) { + public function action($version) + { global $register; Authorization::disable(); if (!array_key_exists($version, Migration::$versions)) { @@ -92,4 +94,4 @@ class Migrate extends Action{ $redis->flushAll(); Console::success('Data Migration Completed'); } -} \ No newline at end of file +} diff --git a/src/Appwrite/Task/SDKs.php b/src/Appwrite/Task/SDKs.php index 9b89dfc7eb..0bbe10bbc9 100644 --- a/src/Appwrite/Task/SDKs.php +++ b/src/Appwrite/Task/SDKs.php @@ -1,4 +1,5 @@ setSkipRenewCheck(true) ->trigger(); } -} \ No newline at end of file +} diff --git a/src/Appwrite/Task/Specs.php b/src/Appwrite/Task/Specs.php index a79f434320..d2e0f73f3c 100644 --- a/src/Appwrite/Task/Specs.php +++ b/src/Appwrite/Task/Specs.php @@ -1,4 +1,5 @@ type = self::TYPE_CLI; diff --git a/src/Appwrite/Task/Usage.php b/src/Appwrite/Task/Usage.php index a9f25a701a..f2f0b73f76 100644 --- a/src/Appwrite/Task/Usage.php +++ b/src/Appwrite/Task/Usage.php @@ -1,4 +1,5 @@ get('db'); $redis = $register->get('cache'); - + $cache = new Cache(new RedisCache($redis)); $database = new Database(new MariaDB($db), $cache); $database->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); $database->setNamespace($namespace); - + if (!$database->exists($database->getDefaultDatabase(), 'projects')) { throw new Exception('Projects collection not ready'); } @@ -48,10 +50,10 @@ class Usage extends Action{ sleep(DATABASE_RECONNECT_SLEEP); } } while ($attempts < DATABASE_RECONNECT_MAX_ATTEMPTS); - + return $database; } - + protected function getInfluxDB(Registry &$register): InfluxDatabase { /** @var InfluxDB\Client $client */ @@ -59,7 +61,7 @@ class Usage extends Action{ $attempts = 0; $max = 10; $sleep = 1; - + do { // check if telegraf database is ready try { $attempts++; @@ -77,17 +79,18 @@ class Usage extends Action{ } while ($attempts < $max); return $database; } - + public function __construct() { - - + + $this ->desc('Schedules syncing data from influxdb to Appwrite console db') ->callback(fn () => $this->action()); } - public function action() { + public function action() + { global $register; @@ -96,34 +99,34 @@ class Usage extends Action{ $logError = function (Throwable $error, string $action = 'syncUsageStats') use ($register) { $logger = $register->get('logger'); - + if ($logger) { $version = App::getEnv('_APP_VERSION', 'UNKNOWN'); - + $log = new Log(); $log->setNamespace("usage"); $log->setServer(\gethostname()); $log->setVersion($version); $log->setType(Log::TYPE_ERROR); $log->setMessage($error->getMessage()); - + $log->addTag('code', $error->getCode()); $log->addTag('verboseType', get_class($error)); - + $log->addExtra('file', $error->getFile()); $log->addExtra('line', $error->getLine()); $log->addExtra('trace', $error->getTraceAsString()); $log->addExtra('detailedTrace', $error->getTrace()); - + $log->setAction($action); - + $isProduction = App::getEnv('_APP_ENV', 'development') === 'production'; $log->setEnvironment($isProduction ? Log::ENVIRONMENT_PRODUCTION : Log::ENVIRONMENT_STAGING); - + $responseCode = $logger->addLog($log); Console::info('Usage stats log pushed with status code: ' . $responseCode); } - + Console::warning("Failed: {$error->getMessage()}"); Console::warning($error->getTraceAsString()); }; @@ -176,4 +179,4 @@ class Usage extends Action{ Console::info("[{$now}] Aggregation took {$loopTook} seconds"); }, $interval); } -} \ No newline at end of file +} diff --git a/src/Appwrite/Task/Vars.php b/src/Appwrite/Task/Vars.php index 818563f362..cd9ff4de6f 100644 --- a/src/Appwrite/Task/Vars.php +++ b/src/Appwrite/Task/Vars.php @@ -1,14 +1,16 @@