Hot reload proactif post-cron pour ratings + mappings + chunks (evite la latence du 1er appel)

This commit is contained in:
unfr
2026-04-24 07:58:22 +02:00
parent fbf99a9ccf
commit 2e84e212ea
3 changed files with 89 additions and 24 deletions

View File

@@ -5,6 +5,7 @@ import secureSession from '@fastify/secure-session';
import fastifyStatic from '@fastify/static';
import Fastify from 'fastify';
import { HOST, PORT, RATE_LIMIT_PER_SEC, ROOT, SESSION_SECRET } from './config.js';
import { startWatchers } from './lib/dataReload.js';
import { preloadMappings } from './lib/imdbMapping.js';
import { getRatings } from './lib/imdbRatings.js';
import { httpDuration, httpRequests, imdbRatingsCount, searchWorkers } from './lib/metrics.js';
@@ -82,9 +83,10 @@ fastify.ready().then(async () => {
searchWorkers.set({ type: 'movie' }, movie.workers.length);
searchWorkers.set({ type: 'tv' }, tv.workers.length);
const maps = await preloadMappings();
startWatchers();
fastify.log.info(
{ ratings: ratings.size, imdb_movie: maps.movie, imdb_tv: maps.tv },
'Warmup complete',
'Warmup complete (data hot-reload watchers started)',
);
} catch (err) {
fastify.log.warn({ err }, 'Warmup failed');