MCPcopy
hub / github.com/directus/directus / waitForDatabase

Function waitForDatabase

api/src/cli/commands/bootstrap/index.ts:79–95  ·  view source on GitHub ↗
(database: Knex)

Source from the content-addressed store, hash-verified

77}
78
79async function waitForDatabase(database: Knex) {
80 const tries = 5;
81 const secondsBetweenTries = 5;
82
83 for (let i = 0; i < tries; i++) {
84 if (await hasDatabaseConnection(database)) {
85 return true;
86 }
87
88 await new Promise((resolve) => setTimeout(resolve, secondsBetweenTries * 1000));
89 }
90
91 // This will throw and exit the process if the database is not available
92 await validateDatabaseConnection(database);
93
94 return database;
95}

Callers 1

bootstrapFunction · 0.85

Calls 2

hasDatabaseConnectionFunction · 0.85

Tested by

no test coverage detected