Prevent database from closing before biometrics have finished.
This commit is contained in:
+21
-4
@@ -863,6 +863,8 @@ async function getActorNames(actorNames) {
|
||||
return actorsWithoutProfiles.rows.map((actor) => actor.name);
|
||||
}
|
||||
|
||||
const pendingBiometrics = new Set();
|
||||
|
||||
async function storeProfiles(profiles) {
|
||||
const profilesWithAvatarIds = await associateAvatars(profiles);
|
||||
const actorIds = Array.from(new Set(profiles.map((profile) => profile.actorId)));
|
||||
@@ -872,10 +874,24 @@ async function storeProfiles(profiles) {
|
||||
await upsertProfiles(profilesWithAvatarIds);
|
||||
await interpolateProfiles(actorIds);
|
||||
|
||||
setBiometrics(Array.from(new Set(profiles.map((profile) => profile.actorId)))).catch((error) => {
|
||||
// biometrics are courtesy, don't await
|
||||
logger.error(`Biometrics failed: ${error.message}`);
|
||||
});
|
||||
// biometrics are courtesy, don't hold up the scrape, but they must finish before the database pool is destroyed
|
||||
const biometricsJob = setBiometrics(actorIds)
|
||||
.catch((error) => {
|
||||
logger.error(`Biometrics failed: ${error.message}`);
|
||||
})
|
||||
.finally(() => {
|
||||
pendingBiometrics.delete(biometricsJob);
|
||||
});
|
||||
|
||||
pendingBiometrics.add(biometricsJob);
|
||||
}
|
||||
|
||||
async function waitForBiometrics() {
|
||||
if (pendingBiometrics.size > 0) {
|
||||
logger.info('Waiting for biometrics to finish');
|
||||
}
|
||||
|
||||
await Promise.all(Array.from(pendingBiometrics));
|
||||
}
|
||||
|
||||
async function scrapeActors(argNames) {
|
||||
@@ -1261,4 +1277,5 @@ module.exports = {
|
||||
scrapeActors,
|
||||
searchActors,
|
||||
toBaseActors,
|
||||
waitForBiometrics,
|
||||
};
|
||||
|
||||
+10
-1
@@ -19,7 +19,14 @@ const fetchUpdates = require('./updates');
|
||||
const { fetchScenes, fetchMovies } = require('./deep');
|
||||
const { storeScenes, storeMovies, associateMovieScenes } = require('./store-releases');
|
||||
const { updateSceneSearch, updateMovieSearch } = require('./update-search');
|
||||
const { scrapeActors, deleteActors, flushActors, flushProfiles, interpolateProfiles } = require('./actors');
|
||||
const {
|
||||
scrapeActors,
|
||||
deleteActors,
|
||||
flushActors,
|
||||
flushProfiles,
|
||||
interpolateProfiles,
|
||||
waitForBiometrics,
|
||||
} = require('./actors');
|
||||
const { flushEntities } = require('./entities');
|
||||
const { deleteScenes, deleteMovies, flushScenes, flushMovies, flushBatches } = require('./releases');
|
||||
const { flushOrphanedMedia, detachReleaseMedia, detachEntityReleaseMedia } = require('./media');
|
||||
@@ -278,6 +285,8 @@ async function init() {
|
||||
await unprint.closeAllBrowsers();
|
||||
await unprint.closeAgents();
|
||||
|
||||
await waitForBiometrics();
|
||||
|
||||
knex.destroy();
|
||||
redis.destroy();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user