refactor(server): filter on-event handlers by worker (#14085)

This commit is contained in:
Jason Rasmussen 2024-11-20 14:08:42 -05:00 committed by GitHub
parent c6e1dbec5c
commit 876893c823
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 24 additions and 70 deletions

View file

@ -31,16 +31,12 @@ export class LibraryService extends BaseService {
private lock = false;
private watchers: Record<string, () => Promise<void>> = {};
@OnEvent({ name: 'config.init' })
@OnEvent({ name: 'config.init', workers: [ImmichWorker.MICROSERVICES] })
async onConfigInit({
newConfig: {
library: { watch, scan },
},
}: ArgOf<'config.init'>) {
if (this.worker !== ImmichWorker.MICROSERVICES) {
return;
}
// This ensures that library watching only occurs in one microservice
this.lock = await this.databaseRepository.tryLock(DatabaseLock.Library);