AI da dat ten cho dong song

This commit is contained in:
2024-10-26 11:10:14 +07:00
parent 2b6d3869f9
commit 48305a3948
11 changed files with 2999 additions and 63 deletions

View File

@@ -42,11 +42,11 @@ export class PrismaService extends PrismaClient implements OnModuleInit {
await this.$connect();
break; // Exit loop if connection is successful
} catch (error) {
if (attempt < 3) {
if (attempt < (parseInt(process.env.PRISMA_MAX_RETRY as string) ?? 3)) {
this.logger.warn(
`Connection attempt ${attempt} failed. Retrying in 5000ms...`,
`Connection attempt ${attempt} failed. Retrying in 10000ms...`,
);
await new Promise((resolve) => setTimeout(resolve, 5000));
await new Promise((resolve) => setTimeout(resolve, 10000));
} else {
this.logger.error(
'Failed to connect to the database after 3 attempts.',