This commit is contained in:
shimon 2024-10-07 11:25:52 +03:00
parent 0cce55565a
commit 5850caff35
3 changed files with 39 additions and 2 deletions

View file

@ -88,7 +88,11 @@ App::post('/v1/projects')
->inject('hooks')
->action(function (string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Request $request, Response $response, Database $dbForConsole, Cache $cache, Group $pools, Hooks $hooks) {
$ctime = time();
var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before getDocument('teams')");
$team = $dbForConsole->getDocument('teams', $teamId);
$diff = time() - $ctime;
var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After getDocument('teams') : " . $diff . " sec");
if ($team->isEmpty()) {
throw new Exception(Exception::TEAM_NOT_FOUND);
@ -154,6 +158,9 @@ App::post('/v1/projects')
}
try {
$ctime = time();
var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before createDocument('projects')");
$project = $dbForConsole->createDocument('projects', new Document([
'$id' => $projectId,
'$permissions' => [
@ -187,6 +194,9 @@ App::post('/v1/projects')
'search' => implode(' ', [$projectId, $name]),
'database' => $dsn,
]));
$diff = time() - $ctime;
var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After createDocument('projects') : " . $diff . " sec");
} catch (Duplicate) {
throw new Exception(Exception::PROJECT_ALREADY_EXISTS);
}
@ -238,7 +248,11 @@ App::post('/v1/projects')
}, $collection['indexes']);
try {
$ctime = time();
var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - Before createCollection('".$key."')");
$dbForProject->createCollection($key, $attributes, $indexes);
$diff = time() - $ctime;
var_dump("[".$region."|".System::getEnv('_APP_REGION')."] - After createCollection('".$key."') : " . $diff . " sec");
} catch (Duplicate) {
// Collection already exists
}

View file

@ -460,6 +460,10 @@ App::init()
/*
* Appwrite Router
*/
$ctime = time();
var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before general first init hook");
$host = $request->getHostname() ?? '';
$mainDomain = System::getEnv('_APP_DOMAIN', '');
// Only run Router when external domain
@ -661,6 +665,9 @@ App::init()
) {
throw new AppwriteException(AppwriteException::GENERAL_UNKNOWN_ORIGIN, $originValidator->getDescription());
}
$diff = time() - $ctime;
var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After general first init hook : " . $diff . " sec");
});
App::options()

View file

@ -162,6 +162,9 @@ App::init()
->inject('mode')
->inject('team')
->action(function (App $utopia, Request $request, Database $dbForConsole, Document $project, Document $user, ?Document $session, array $servers, string $mode, Document $team) {
$ctime = time();
var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api first init hook");
$route = $utopia->getRoute();
if ($project->isEmpty()) {
@ -344,6 +347,8 @@ App::init()
throw new Exception(Exception::USER_MORE_FACTORS_REQUIRED);
}
}
$diff = time() - $ctime;
var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api first init hook : " . $diff . " sec");
});
App::init()
@ -363,7 +368,8 @@ App::init()
->inject('dbForProject')
->inject('mode')
->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Messaging $queueForMessaging, Audit $queueForAudits, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Usage $queueForUsage, Database $dbForProject, string $mode) use ($databaseListener) {
$ctime = time();
var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api second init hook");
$route = $utopia->getRoute();
if (
@ -521,6 +527,8 @@ App::init()
;
}
}
$diff = time() - $ctime;
var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api second init hook : " . $diff . " sec");
});
App::init()
@ -551,6 +559,8 @@ App::shutdown()
->inject('project')
->inject('dbForProject')
->action(function (App $utopia, Request $request, Response $response, Document $project, Database $dbForProject) {
var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api first shutdown hook");
$route = $utopia->getRoute();
$sessionLimit = $project->getAttribute('auths', [])['maxSessions'] ?? APP_LIMIT_USER_SESSIONS_DEFAULT;
$session = $response->getPayload();
$userId = $session['userId'] ?? '';
@ -575,6 +585,8 @@ App::shutdown()
}
$dbForProject->purgeCachedDocument('users', $userId);
$diff = time() - $ctime;
var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api first shutdown hook : " . $diff . " sec");
});
App::shutdown()
@ -597,7 +609,9 @@ App::shutdown()
->inject('dbForConsole')
->inject('realtimeConnection')
->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Audit $queueForAudits, Usage $queueForUsage, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Messaging $queueForMessaging, Database $dbForProject, Func $queueForFunctions, string $mode, Database $dbForConsole, callable $realtimeConnection) use ($parseLabel) {
$ctime = time();
var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - Before shared api second shutdown hook");
$route = $utopia->getRoute();
$responsePayload = $response->getPayload();
if (!empty($queueForEvents->getEvent())) {
@ -800,6 +814,8 @@ App::shutdown()
}
}
}
$diff = time() - $ctime;
var_dump("[".$project->getAttribute('region')."|".System::getEnv('_APP_REGION')."] - After shared api second shutdown hook : " . $diff . " sec");
});
App::init()