fix initDatabase function by proper use of await in try catch (#2360)
* fix initDatabase function by proper use of await in try catch * lint-fix --------- Co-authored-by: Henry Heng <henryheng@flowiseai.com>
This commit is contained in:
parent
ee9d3a33fa
commit
823cefb5c5
|
|
@ -43,40 +43,39 @@ export class App {
|
|||
|
||||
async initDatabase() {
|
||||
// Initialize database
|
||||
this.AppDataSource.initialize()
|
||||
.then(async () => {
|
||||
logger.info('📦 [server]: Data Source is initializing...')
|
||||
try {
|
||||
await this.AppDataSource.initialize()
|
||||
logger.info('📦 [server]: Data Source is initializing...')
|
||||
|
||||
// Run Migrations Scripts
|
||||
await this.AppDataSource.runMigrations({ transaction: 'each' })
|
||||
// Run Migrations Scripts
|
||||
await this.AppDataSource.runMigrations({ transaction: 'each' })
|
||||
|
||||
// Initialize nodes pool
|
||||
this.nodesPool = new NodesPool()
|
||||
await this.nodesPool.initialize()
|
||||
// Initialize nodes pool
|
||||
this.nodesPool = new NodesPool()
|
||||
await this.nodesPool.initialize()
|
||||
|
||||
// Initialize chatflow pool
|
||||
this.chatflowPool = new ChatflowPool()
|
||||
// Initialize chatflow pool
|
||||
this.chatflowPool = new ChatflowPool()
|
||||
|
||||
// Initialize API keys
|
||||
await getAPIKeys()
|
||||
// Initialize API keys
|
||||
await getAPIKeys()
|
||||
|
||||
// Initialize encryption key
|
||||
await getEncryptionKey()
|
||||
// Initialize encryption key
|
||||
await getEncryptionKey()
|
||||
|
||||
// Initialize Rate Limit
|
||||
const AllChatFlow: IChatFlow[] = await getAllChatFlow()
|
||||
await initializeRateLimiter(AllChatFlow)
|
||||
// Initialize Rate Limit
|
||||
const AllChatFlow: IChatFlow[] = await getAllChatFlow()
|
||||
await initializeRateLimiter(AllChatFlow)
|
||||
|
||||
// Initialize cache pool
|
||||
this.cachePool = new CachePool()
|
||||
// Initialize cache pool
|
||||
this.cachePool = new CachePool()
|
||||
|
||||
// Initialize telemetry
|
||||
this.telemetry = new Telemetry()
|
||||
logger.info('📦 [server]: Data Source has been initialized!')
|
||||
})
|
||||
.catch((err) => {
|
||||
logger.error('❌ [server]: Error during Data Source initialization:', err)
|
||||
})
|
||||
// Initialize telemetry
|
||||
this.telemetry = new Telemetry()
|
||||
logger.info('📦 [server]: Data Source has been initialized!')
|
||||
} catch (error) {
|
||||
logger.error('❌ [server]: Error during Data Source initialization:', error)
|
||||
}
|
||||
}
|
||||
|
||||
async config(socketIO?: Server) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue