Add more logs for tg bot (#8829)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2025-05-05 12:54:28 +04:00 committed by GitHub
parent 73e5ca9ad0
commit fed840f56e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -55,6 +55,7 @@ Analytics.setTag('application', 'telegram-bot-service')
export async function requestReconnect (bot: Telegraf<TgContext>, limiter: Limiter): Promise<void> {
if (config.MongoDB === '' || config.MongoURL === '') {
ctx.info('MongoDB is not configured, skipping reconnect')
return
}
@ -84,11 +85,15 @@ export const start = async (): Promise<void> => {
setMetadata(serverClient.metadata.UserAgent, config.ServiceId)
registerLoaders()
ctx.info('Creating worker...')
const worker = await PlatformWorker.create(ctx)
ctx.info('Set up bot...')
const bot = await setUpBot(worker)
ctx.info('Creating server...')
const app = createServer(bot, worker, ctx)
ctx.info('Creating queue...')
const queue = getPlatformQueue('telegramBotService', config.QueueRegion)
ctx.info('queue', { clientId: queue.getClientId() })
if (config.Domain === '') {
ctx.info('Starting bot with polling')
@ -110,7 +115,9 @@ export const start = async (): Promise<void> => {
res.status(200).send()
})
ctx.info('Requesting reconnect...')
await requestReconnect(bot, worker.limiter)
ctx.info('Starting server...')
const server = listen(app, ctx, config.Port)
const consumer = queue.createConsumer<TelegramQueueMessage>(

View File

@ -87,7 +87,9 @@ export class PlatformWorker {
const storageConfig: StorageConfiguration = storageConfigFromEnv()
const storage = buildStorageFromConfig(storageConfig)
ctx.info('Connecting to database...', { dbUrl: config.DbUrl })
const db = await getDb()
ctx.info('Database connected')
const limiter = new Limiter()
return new PlatformWorker(ctx, storage, limiter, db)