From c5adbea6e131303b389533903c53361d3876ae84 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 11 May 2022 06:18:11 -0500 Subject: [PATCH] Fixed incorrect microservices URLs after updating dockerfiles (#159) --- .../image-classifier.controller.ts | 2 +- .../object-detection.controller.ts | 3 +- .../background-task.processor.ts | 29 +++++++++++-------- .../background-task.service.ts | 2 +- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/microservices/src/image-classifier/image-classifier.controller.ts b/microservices/src/image-classifier/image-classifier.controller.ts index 87393a1c56..5dbe8bdffe 100644 --- a/microservices/src/image-classifier/image-classifier.controller.ts +++ b/microservices/src/image-classifier/image-classifier.controller.ts @@ -5,7 +5,7 @@ import { ImageClassifierService } from './image-classifier.service'; export class ImageClassifierController { constructor( private readonly imageClassifierService: ImageClassifierService, - ) {} + ) { } @Post('/tagImage') async tagImage(@Body('thumbnailPath') thumbnailPath: string) { diff --git a/microservices/src/object-detection/object-detection.controller.ts b/microservices/src/object-detection/object-detection.controller.ts index 5265b8b54f..77ec167b8d 100644 --- a/microservices/src/object-detection/object-detection.controller.ts +++ b/microservices/src/object-detection/object-detection.controller.ts @@ -1,11 +1,12 @@ import { Body, Controller, Post } from '@nestjs/common'; import { ObjectDetectionService } from './object-detection.service'; +import { Logger } from '@nestjs/common'; @Controller('object-detection') export class ObjectDetectionController { constructor( private readonly objectDetectionService: ObjectDetectionService, - ) {} + ) { } @Post('/detectObject') async detectObject(@Body('thumbnailPath') thumbnailPath: string) { diff --git a/server/src/modules/background-task/background-task.processor.ts b/server/src/modules/background-task/background-task.processor.ts index 49f29226e3..98f7369f70 100644 --- a/server/src/modules/background-task/background-task.processor.ts +++ b/server/src/modules/background-task/background-task.processor.ts @@ -115,7 +115,7 @@ export class BackgroundTaskProcessor { async tagImage(job) { const { thumbnailPath, asset }: { thumbnailPath: string; asset: AssetEntity } = job.data; - const res = await axios.post('http://immich_microservices:3001/image-classifier/tagImage', { + const res = await axios.post('http://immich-microservices:3001/image-classifier/tagImage', { thumbnailPath: thumbnailPath, }); @@ -132,19 +132,24 @@ export class BackgroundTaskProcessor { @Process('detect-object') async detectObject(job) { - const { thumbnailPath, asset }: { thumbnailPath: string; asset: AssetEntity } = job.data; + try { + const { thumbnailPath, asset }: { thumbnailPath: string; asset: AssetEntity } = job.data; - const res = await axios.post('http://immich_microservices:3001/object-detection/detectObject', { - thumbnailPath: thumbnailPath, - }); - - if (res.status == 201 && res.data.length > 0) { - const smartInfo = new SmartInfoEntity(); - smartInfo.assetId = asset.id; - smartInfo.objects = [...res.data]; - await this.smartInfoRepository.upsert(smartInfo, { - conflictPaths: ['assetId'], + const res = await axios.post('http://immich-microservices:3001/object-detection/detectObject', { + thumbnailPath: thumbnailPath, }); + + if (res.status == 201 && res.data.length > 0) { + const smartInfo = new SmartInfoEntity(); + smartInfo.assetId = asset.id; + smartInfo.objects = [...res.data]; + await this.smartInfoRepository.upsert(smartInfo, { + conflictPaths: ['assetId'], + }); + } + } catch (error) { + Logger.error(`Failed to trigger object detection pipe line ${error.toString()}`) } + } } diff --git a/server/src/modules/background-task/background-task.service.ts b/server/src/modules/background-task/background-task.service.ts index d25989c1b8..1a62ce54d5 100644 --- a/server/src/modules/background-task/background-task.service.ts +++ b/server/src/modules/background-task/background-task.service.ts @@ -9,7 +9,7 @@ export class BackgroundTaskService { constructor( @InjectQueue('background-task') private backgroundTaskQueue: Queue, - ) {} + ) { } async extractExif(savedAsset: AssetEntity, fileName: string, fileSize: number) { await this.backgroundTaskQueue.add(