mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-22 19:06:41 +02:00
🔧 fix(telegram-bot): improve database connection logging and error messages
- Add connection test on startup (SELECT 1) - Log masked database URL on connection attempt - Better error messages for /users command
This commit is contained in:
parent
79e3c09af2
commit
021c6e789e
2 changed files with 23 additions and 9 deletions
|
|
@ -31,10 +31,16 @@ export class UsersService implements OnModuleInit {
|
|||
async onModuleInit() {
|
||||
if (this.databaseUrl) {
|
||||
try {
|
||||
// Mask password in logs
|
||||
const maskedUrl = this.databaseUrl.replace(/:([^@]+)@/, ':****@');
|
||||
this.logger.log(`Connecting to database: ${maskedUrl}`);
|
||||
this.sql = postgres(this.databaseUrl);
|
||||
this.logger.log('Database connection initialized');
|
||||
// Test connection
|
||||
await this.sql`SELECT 1`;
|
||||
this.logger.log('Database connection initialized and tested successfully');
|
||||
} catch (error) {
|
||||
this.logger.warn('Failed to initialize database connection:', error);
|
||||
this.logger.error('Failed to initialize database connection:', error);
|
||||
this.sql = null;
|
||||
}
|
||||
} else {
|
||||
this.logger.warn('DATABASE_URL not configured, user stats will be unavailable');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue