mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
fix(server): reverse geocoding crash loop (#2489)
This commit is contained in:
@@ -4,6 +4,7 @@ import { SERVER_VERSION } from '@app/domain';
|
||||
import { getLogLevels } from '@app/domain';
|
||||
import { RedisIoAdapter } from '@app/infra';
|
||||
import { MicroservicesModule } from './microservices.module';
|
||||
import { MetadataExtractionProcessor } from './processors/metadata-extraction.processor';
|
||||
|
||||
const logger = new Logger('ImmichMicroservice');
|
||||
|
||||
@@ -16,6 +17,20 @@ async function bootstrap() {
|
||||
|
||||
app.useWebSocketAdapter(new RedisIoAdapter(app));
|
||||
|
||||
const metadataService = app.get(MetadataExtractionProcessor);
|
||||
|
||||
process.on('uncaughtException', (error: Error | any) => {
|
||||
const isCsvError = error.code === 'CSV_RECORD_INCONSISTENT_FIELDS_LENGTH';
|
||||
if (!isCsvError) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
logger.warn('Geocoding csv parse error, trying again without cache...');
|
||||
metadataService.init(true);
|
||||
});
|
||||
|
||||
await metadataService.init();
|
||||
|
||||
await app.listen(listeningPort, () => {
|
||||
const envName = (process.env.NODE_ENV || 'development').toUpperCase();
|
||||
logger.log(
|
||||
@@ -23,4 +38,5 @@ async function bootstrap() {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
bootstrap();
|
||||
|
||||
@@ -46,16 +46,18 @@ export class MetadataExtractionProcessor {
|
||||
) {
|
||||
this.assetCore = new AssetCore(assetRepository, jobRepository);
|
||||
this.reverseGeocodingEnabled = !configService.get('DISABLE_REVERSE_GEOCODING');
|
||||
this.init();
|
||||
}
|
||||
|
||||
private async init() {
|
||||
async init(skipCache = false) {
|
||||
this.logger.warn(`Reverse geocoding is ${this.reverseGeocodingEnabled ? 'enabled' : 'disabled'}`);
|
||||
if (!this.reverseGeocodingEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!skipCache) {
|
||||
await this.geocodingRepository.deleteCache();
|
||||
}
|
||||
this.logger.log('Initializing Reverse Geocoding');
|
||||
|
||||
await this.jobRepository.pause(QueueName.METADATA_EXTRACTION);
|
||||
|
||||
Reference in New Issue
Block a user