New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(server): Move library watcher to microservices #7533
Conversation
Deploying with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good so far, but you need to prevent library scanning from running on installs which run multiple instances of microservices. I think you can accomplish this by asking for a postgres lock, although you might need to get more info from @zackpollard or @mertalev on that.
My test shows the current lock implementation did not work as expected, will have to do some debugging later:
only one microservice should have initiated the watch |
The return type is an array:
|
Yeah, I have to get used to ts not doing runtime type checking. Thanks :) |
…e/library-init-micro
This reverts commit 84ab5ab.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…e/library-init-micro
…e/library-init-micro
…e/library-init-micro
* move watcher init to micro * document watcher recovery * chore: fix lint * add try lock * use global library watch lock * fix: ensure lock stays on * fix: mocks * unit test for library watch lock * move statement to correct test * fix: correct return type of try lock * fix: tests * add library teardown * add chokidar error handler * make event strings an enum * wait for event refactor * refactor event type mocks * expect correct error * don't release lock in teardown * chore: lint * use enum * fix mock * fix lint * fix watcher await * remove await * simplify typing * remove async * Revert "remove async" This reverts commit 84ab5ab. * can now change watch settings at runtime * fix lint * only watch libraries if enabled --------- Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com> Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This moves the library watcher to be running in the microservices.
Inspiration is from @jrasm91 who suggested this as a better option to #7509.
Here, if the watcher fails and stalls (as in #6833) we can stop the microservices container and disable the library watcher, unbricking the Immich install in a clean way
Added lock so that only one microservice takes care of the watcher in the case of multiple micros
Tests performed: