feat(core): Improve health check (#6205)

* remove unnecesary Db re-initialization

this is from before we added `Db.init` in `WorkflowRunnerProcess`

* feat(core): Improved health check

* make health check not care about DB connections

* close DB connections, and shutdown the timer
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-05-10 08:27:04 +00:00
committed by GitHub
parent e3f47994b1
commit 9e7b9fb443
9 changed files with 184 additions and 153 deletions

View File

@@ -58,7 +58,7 @@ export async function init() {
if (dbType === 'sqlite') {
// no bootstrap connection required
return Db.init(getSqliteOptions({ name: testDbName }));
await Db.init(getSqliteOptions({ name: testDbName }));
}
if (dbType === 'postgresdb') {
@@ -89,7 +89,7 @@ export async function init() {
await bootstrapPostgres.query(`CREATE DATABASE ${testDbName}`);
await bootstrapPostgres.destroy();
return Db.init(getDBOptions('postgres', testDbName));
await Db.init(getDBOptions('postgres', testDbName));
}
if (dbType === 'mysqldb') {
@@ -97,18 +97,17 @@ export async function init() {
await bootstrapMysql.query(`CREATE DATABASE ${testDbName}`);
await bootstrapMysql.destroy();
return Db.init(getDBOptions('mysql', testDbName));
await Db.init(getDBOptions('mysql', testDbName));
}
throw new Error(`Unrecognized DB type: ${dbType}`);
await Db.migrate();
}
/**
* Drop test DB, closing bootstrap connection if existing.
*/
export async function terminate() {
const connection = Db.getConnection();
if (connection.isInitialized) await connection.destroy();
await Db.close();
}
/**