Sleep 10 seconds before ending the process after critical error in database migration
This commit is contained in:
parent
ae2cb05dc5
commit
f494bd6d6a
@ -3,13 +3,14 @@ import config from '../config';
|
|||||||
import { DB } from '../database';
|
import { DB } from '../database';
|
||||||
import logger from '../logger';
|
import logger from '../logger';
|
||||||
|
|
||||||
|
const sleep = (ms: number) => new Promise( res => setTimeout(res, ms));
|
||||||
|
|
||||||
class DatabaseMigration {
|
class DatabaseMigration {
|
||||||
private static currentVersion = 2;
|
private static currentVersion = 2;
|
||||||
private queryTimeout = 120000;
|
private queryTimeout = 120000;
|
||||||
private statisticsAddedIndexed = false;
|
private statisticsAddedIndexed = false;
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point
|
* Entry point
|
||||||
*/
|
*/
|
||||||
@ -24,7 +25,8 @@ class DatabaseMigration {
|
|||||||
try {
|
try {
|
||||||
await this.$createMigrationStateTable();
|
await this.$createMigrationStateTable();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.err('Unable to create `state` table. Aborting migration. ' + e);
|
logger.err('Unable to create `state` table, aborting in 10 seconds. ' + e);
|
||||||
|
await sleep(10000);
|
||||||
process.exit(-1);
|
process.exit(-1);
|
||||||
}
|
}
|
||||||
logger.info('MIGRATIONS: `state` table initialized.');
|
logger.info('MIGRATIONS: `state` table initialized.');
|
||||||
@ -34,7 +36,8 @@ class DatabaseMigration {
|
|||||||
try {
|
try {
|
||||||
databaseSchemaVersion = await this.$getSchemaVersionFromDatabase();
|
databaseSchemaVersion = await this.$getSchemaVersionFromDatabase();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.err('Unable to get current database migration version, aborting. ' + e);
|
logger.err('Unable to get current database migration version, aborting in 10 seconds. ' + e);
|
||||||
|
await sleep(10000);
|
||||||
process.exit(-1);
|
process.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +52,8 @@ class DatabaseMigration {
|
|||||||
try {
|
try {
|
||||||
await this.$createMissingTablesAndIndexes(databaseSchemaVersion);
|
await this.$createMissingTablesAndIndexes(databaseSchemaVersion);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.err('Unable to create required tables, aborting. ' + e);
|
logger.err('Unable to create required tables, aborting in 10 seconds. ' + e);
|
||||||
|
await sleep(10000);
|
||||||
process.exit(-1);
|
process.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user