mirror of
https://github.com/immich-app/immich.git
synced 2026-03-04 09:57:33 +03:00
fix(server): auto-reconnect to database (#12320)
This commit is contained in:
@@ -31,6 +31,19 @@ export class DatabaseRepository implements IDatabaseRepository {
|
||||
this.logger.setContext(DatabaseRepository.name);
|
||||
}
|
||||
|
||||
async reconnect() {
|
||||
try {
|
||||
if (this.dataSource.isInitialized) {
|
||||
await this.dataSource.destroy();
|
||||
}
|
||||
const { isInitialized } = await this.dataSource.initialize();
|
||||
return isInitialized;
|
||||
} catch (error) {
|
||||
this.logger.error(`Database connection failed: ${error}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async getExtensionVersion(extension: DatabaseExtension): Promise<ExtensionVersion> {
|
||||
const [res]: ExtensionVersion[] = await this.dataSource.query(
|
||||
`SELECT default_version as "availableVersion", installed_version as "installedVersion"
|
||||
|
||||
@@ -3,7 +3,7 @@ import { isLogLevelEnabled } from '@nestjs/common/services/utils/is-log-level-en
|
||||
import { ClsService } from 'nestjs-cls';
|
||||
import { LogLevel } from 'src/config';
|
||||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
import { LogColor } from 'src/utils/logger-colors';
|
||||
import { LogColor } from 'src/utils/logger';
|
||||
|
||||
const LOG_LEVELS = [LogLevel.VERBOSE, LogLevel.DEBUG, LogLevel.LOG, LogLevel.WARN, LogLevel.ERROR, LogLevel.FATAL];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user