datasquirel/package-shared/utils/docker-test-maxscale-connection.ts
Benjamin Toby c37d105dee Updates
2025-07-09 20:30:45 +01:00

41 lines
1.1 KiB
TypeScript

import debugLog from "./logging/debug-log";
import mariaDBlocalQuery from "./mariadb-local-query";
let checkDbRetries = 0;
const MAX_CHECK_DB_RETRIES = 10;
const DEFAULT_SLEEP_TIME = 3000;
type Params = {
maxRetries?: number;
sleepTime?: number;
};
export default async function dockerTestMaxscaleConnection(params?: Params) {
const maxRetries = params?.maxRetries || MAX_CHECK_DB_RETRIES;
const sleepTime = params?.sleepTime || DEFAULT_SLEEP_TIME;
// while (true) {
// if (checkDbRetries > maxRetries) {
// debugLog({
// log: `Max Retries for checking Database. Exiting ...`,
// addTime: true,
// label: "MaxRetries",
// });
// process.exit(1);
// }
// const checkDb = mariaDBlocalQuery(`SHOW DATABASES`);
// const isDbReady =
// typeof checkDb == "string" &&
// Boolean(checkDb.match(/\ninformation_schema\n/));
// if (isDbReady) {
// break;
// } else {
// checkDbRetries++;
// await Bun.sleep(sleepTime);
// }
// }
}