use global library watch lock
This commit is contained in:
@@ -70,8 +70,16 @@ export class LibraryService extends EventEmitter {
|
||||
|
||||
async init() {
|
||||
const config = await this.configCore.getConfig();
|
||||
|
||||
const { watch, scan } = config.library;
|
||||
this.watchLibraries = watch.enabled;
|
||||
this.watchLibraries = false;
|
||||
if (watch.enabled) {
|
||||
this.databaseRepository.withTryLock(DatabaseLock.LibraryWatch, async () => {
|
||||
// This ensures that library watching only occurs in one microservice
|
||||
// TODO: we could make the lock be per-library instead of global
|
||||
this.watchLibraries = true;
|
||||
});
|
||||
}
|
||||
this.jobRepository.addCronJob(
|
||||
'libraryScan',
|
||||
scan.cronExpression,
|
||||
@@ -106,7 +114,6 @@ export class LibraryService extends EventEmitter {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.databaseRepository.withTryLock(DatabaseLock.LibraryWatch, async () => {
|
||||
await this.unwatch(id);
|
||||
|
||||
this.logger.log(`Starting to watch library ${library.id} with import path(s) ${library.importPaths}`);
|
||||
@@ -159,7 +166,6 @@ export class LibraryService extends EventEmitter {
|
||||
|
||||
// Wait for the watcher to initialize before returning
|
||||
await ready$;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user