Skip to content

Commit 7824320

Browse files
committed
remove db monitor
1 parent 52f5b3f commit 7824320

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/bot.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable import/first */
22
import * as Events from 'events'
33
Events.EventEmitter.defaultMaxListeners = 30
4+
45
import { Sentry } from './monitoring/instrument'
56
import express from 'express'
67
import asyncHandler from 'express-async-handler'
@@ -865,20 +866,26 @@ async function bootstrap (): Promise<void> {
865866
}, restartDelay)
866867
}
867868

868-
if (dbConnected) {
869-
// Periodically check database connection and attempt to reconnect if needed
870-
setInterval(() => {
871-
void (async () => {
872-
try {
873-
if (!AppDataSource.isInitialized) {
874-
logger.warn('Database connection lost, attempting to reconnect...')
875-
await connectToDatabase(3) // Use fewer retries for periodic checks
876-
}
877-
} catch (error) {
878-
logger.error(`Database monitoring error: ${(error as Error).message}`)
879-
}
880-
})()
881-
}, 5 * 60 * 1000) // Check every minute
869+
try {
870+
payments.bootstrap()
871+
} catch (error) {
872+
logger.error(`Payments bootstrap error: ${error}`)
873+
// Continue despite payment initialization errors
874+
}
875+
876+
if (dbConnected && AppDataSource.driver) {
877+
try {
878+
// Handle any driver-level errors that bubble up
879+
const driver = AppDataSource.driver as any
880+
// Only attach to events if they're available, don't force it
881+
if (driver.eventEmitter && typeof driver.eventEmitter.on === 'function') {
882+
driver.eventEmitter.on('error', (error: any) => {
883+
logger.error(`Database error event: ${error.message}`)
884+
})
885+
}
886+
} catch (error) {
887+
logger.warn(`Could not set up database error listener: ${(error as Error).message}`)
888+
}
882889
}
883890
}
884891

0 commit comments

Comments
 (0)