0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

refactor(core): optimize init (#5826)

This commit is contained in:
Gao Sun 2024-05-06 17:12:36 +08:00 committed by GitHub
parent 95682f72a1
commit 4397ca29ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View file

@ -1,8 +1,10 @@
import { appInsights } from '@logto/app-insights/node';
import { ConsoleLog } from '@logto/shared';
import { trySafe } from '@silverhand/essentials';
import chalk from 'chalk';
import Koa from 'koa';
import initApp from './app/init.js';
import { redisCache } from './caches/index.js';
import { checkAlterationState } from './env-set/check-alteration-state.js';
import { EnvSet } from './env-set/index.js';
@ -11,7 +13,6 @@ import SystemContext from './tenants/SystemContext.js';
import { checkRowLevelSecurity, tenantPool } from './tenants/index.js';
import { loadConnectorFactories } from './utils/connectors/index.js';
const { appInsights } = await import('@logto/app-insights/node');
const consoleLog = new ConsoleLog(chalk.magenta('index'));
if (await appInsights.setup('core')) {
@ -33,8 +34,6 @@ try {
SystemContext.shared.loadProviderConfigs(sharedAdminPool),
]);
// Import last until init completed
const { default: initApp } = await import('./app/init.js');
await initApp(app);
} catch (error: unknown) {
consoleLog.error('Error while initializing app:');

View file

@ -31,7 +31,7 @@ class TenantPool {
// Otherwise, create a new tenant instance and store in LRU cache, using the code below.
}
consoleLog.info('Init tenant:', tenantId, customDomain);
consoleLog.info('Init tenant:', tenantId, 'Custom domain:', customDomain);
const newTenantPromise = Tenant.create({ id: tenantId, redisCache, customDomain });
this.cache.set(cacheKey, newTenantPromise);