mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
Removing memory DB fallback in case of DB error.
App now terminates on an error. Fixes #163
This commit is contained in:
parent
acd3cf1fe5
commit
161e291939
@ -3,7 +3,6 @@ import {NextFunction, Request, Response} from 'express';
|
|||||||
import {ErrorCodes, ErrorDTO} from '../../../common/entities/Error';
|
import {ErrorCodes, ErrorDTO} from '../../../common/entities/Error';
|
||||||
import {ObjectManagers} from '../../model/ObjectManagers';
|
import {ObjectManagers} from '../../model/ObjectManagers';
|
||||||
import {Logger} from '../../Logger';
|
import {Logger} from '../../Logger';
|
||||||
import {SQLConnection} from '../../model/database/sql/SQLConnection';
|
|
||||||
import {Config} from '../../../common/config/private/Config';
|
import {Config} from '../../../common/config/private/Config';
|
||||||
import {ConfigDiagnostics} from '../../model/diagnostics/ConfigDiagnostics';
|
import {ConfigDiagnostics} from '../../model/diagnostics/ConfigDiagnostics';
|
||||||
import {BasicConfigDTO} from '../../../common/entities/settings/BasicConfigDTO';
|
import {BasicConfigDTO} from '../../../common/entities/settings/BasicConfigDTO';
|
||||||
@ -27,7 +26,7 @@ export class SettingsMWs {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (databaseSettings.type !== ServerConfig.DatabaseType.memory) {
|
if (databaseSettings.type !== ServerConfig.DatabaseType.memory) {
|
||||||
await SQLConnection.tryConnection(databaseSettings);
|
await ConfigDiagnostics.testDatabase(databaseSettings);
|
||||||
}
|
}
|
||||||
Config.Server.Database = databaseSettings;
|
Config.Server.Database = databaseSettings;
|
||||||
// only updating explicitly set config (not saving config set by the diagnostics)
|
// only updating explicitly set config (not saving config set by the diagnostics)
|
||||||
|
@ -215,14 +215,8 @@ export class ConfigDiagnostics {
|
|||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
const err: Error = ex;
|
const err: Error = ex;
|
||||||
Logger.warn(LOG_TAG, '[SQL error]', err.toString());
|
Logger.warn(LOG_TAG, '[SQL error]', err.toString());
|
||||||
if (Config.Server.Database.enableFallback === true) {
|
Logger.error(LOG_TAG, 'Error during initializing SQL DB, check DB connection and settings');
|
||||||
Logger.warn(LOG_TAG, 'Error during initializing SQL falling back temporally to memory DB');
|
process.exit(1);
|
||||||
NotificationManager.warning('Error during initializing SQL falling back temporally to memory DB', err.toString());
|
|
||||||
Config.Server.Database.type = ServerConfig.DatabaseType.memory;
|
|
||||||
} else {
|
|
||||||
Logger.error(LOG_TAG, 'Error during initializing SQL DB, check DB connection and settings');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,9 +66,6 @@ export module ServerConfig {
|
|||||||
})
|
})
|
||||||
type: DatabaseType = DatabaseType.sqlite;
|
type: DatabaseType = DatabaseType.sqlite;
|
||||||
|
|
||||||
@ConfigProperty({description: 'In the case of bad database settings (or unreachable database), the app falls back using inmemory database, otherwise terminates the app.'})
|
|
||||||
enableFallback: boolean = true;
|
|
||||||
|
|
||||||
@ConfigProperty()
|
@ConfigProperty()
|
||||||
dbFolder: string = 'db';
|
dbFolder: string = 'db';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user