fix: 优化数据库连接配置和超时设置
- 禁用云函数环境下的自动迁移 - 增加连接超时和重试机制配置 - 优化连接池参数设置 - 提升数据库连接稳定性和性能
This commit is contained in:
parent
489756b7a0
commit
54a1bf141b
|
|
@ -20,7 +20,19 @@ export const databaseConfig = (
|
|||
'DB_LOGGING',
|
||||
process.env.NODE_ENV === 'development',
|
||||
),
|
||||
migrationsRun: configService.get<boolean>('DB_MIGRATIONS_RUN', true), // 自动运行迁移
|
||||
migrationsRun: configService.get<boolean>('DB_MIGRATIONS_RUN', false), // 云函数环境禁用自动迁移
|
||||
charset: 'utf8mb4',
|
||||
timezone: '+08:00',
|
||||
// 添加连接超时和重试配置
|
||||
connectTimeout: 60000, // 60秒连接超时
|
||||
acquireTimeout: 60000, // 60秒获取连接超时
|
||||
retryAttempts: 3, // 重试3次
|
||||
retryDelay: 3000, // 重试间隔3秒
|
||||
// 连接池配置
|
||||
extra: {
|
||||
connectionLimit: 10,
|
||||
idleTimeout: 30000,
|
||||
acquireTimeout: 60000,
|
||||
timeout: 60000, // 60秒查询超时
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue