mirror of
https://github.com/bpatrik/pigallery2.git
synced 2024-12-12 11:15:22 +02: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 {ObjectManagers} from '../../model/ObjectManagers';
|
||||
import {Logger} from '../../Logger';
|
||||
import {SQLConnection} from '../../model/database/sql/SQLConnection';
|
||||
import {Config} from '../../../common/config/private/Config';
|
||||
import {ConfigDiagnostics} from '../../model/diagnostics/ConfigDiagnostics';
|
||||
import {BasicConfigDTO} from '../../../common/entities/settings/BasicConfigDTO';
|
||||
@ -27,7 +26,7 @@ export class SettingsMWs {
|
||||
|
||||
try {
|
||||
if (databaseSettings.type !== ServerConfig.DatabaseType.memory) {
|
||||
await SQLConnection.tryConnection(databaseSettings);
|
||||
await ConfigDiagnostics.testDatabase(databaseSettings);
|
||||
}
|
||||
Config.Server.Database = databaseSettings;
|
||||
// only updating explicitly set config (not saving config set by the diagnostics)
|
||||
|
@ -215,14 +215,8 @@ export class ConfigDiagnostics {
|
||||
} catch (ex) {
|
||||
const err: Error = ex;
|
||||
Logger.warn(LOG_TAG, '[SQL error]', err.toString());
|
||||
if (Config.Server.Database.enableFallback === true) {
|
||||
Logger.warn(LOG_TAG, 'Error during initializing SQL falling back temporally to memory DB');
|
||||
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);
|
||||
}
|
||||
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;
|
||||
|
||||
@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()
|
||||
dbFolder: string = 'db';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user