Skip to content

Commit

Permalink
Optimize waking up
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelblaszczyk5 committed Jan 5, 2024
1 parent 61056e9 commit f93f998
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions prisma/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ if (!DATABASE_PUBLIC_URL) {
throw new Error('DATABASE_PUBLIC_URL must be defined for waking up db');
}

const tryWakingUpDatabase = async () => {
const tryWakingUpDatabase = () => {
console.log('Trying to wake up database via public URL');

try {
await new PrismaClient({ datasources: { db: { url: DATABASE_PUBLIC_URL } } }).$connect();
new PrismaClient({ datasources: { db: { url: DATABASE_PUBLIC_URL } } }).$connect();
} catch {
/* empty */
}
Expand All @@ -38,8 +38,6 @@ const deployPrismaMigrationsWithRetrying = () => {

if (!isDatabaseUnavailable) throw error;

await tryWakingUpDatabase();

const delayMs = BASE_DELAY * 2 ** currentRetry;
currentRetry += 1;

Expand All @@ -56,4 +54,5 @@ const deployPrismaMigrationsWithRetrying = () => {
return execute();
};

tryWakingUpDatabase();
await deployPrismaMigrationsWithRetrying();

0 comments on commit f93f998

Please sign in to comment.