Dashboard admin : split stats/disk + preload disk au warmup + wc -l (1.85s -> 40ms)
This commit is contained in:
@@ -10,6 +10,7 @@ import { preloadMappings } from './lib/imdbMapping.js';
|
||||
import { getRatings } from './lib/imdbRatings.js';
|
||||
import { httpDuration, httpRequests, imdbRatingsCount, searchWorkers } from './lib/metrics.js';
|
||||
import { getPool } from './lib/searchEngine.js';
|
||||
import { preloadDiskUsage } from './lib/stats.js';
|
||||
import adminRoutes from './routes/admin.js';
|
||||
import apiRoutes from './routes/api.js';
|
||||
import healthRoutes from './routes/health.js';
|
||||
@@ -84,9 +85,12 @@ fastify.ready().then(async () => {
|
||||
searchWorkers.set({ type: 'tv' }, tv.workers.length);
|
||||
const maps = await preloadMappings();
|
||||
startWatchers();
|
||||
// Disk usage takes ~3 s on cold cache (du -sb on 1.7M files). Run it in
|
||||
// background so the first admin visitor finds the result already cached.
|
||||
preloadDiskUsage();
|
||||
fastify.log.info(
|
||||
{ ratings: ratings.size, imdb_movie: maps.movie, imdb_tv: maps.tv },
|
||||
'Warmup complete (data hot-reload watchers started)',
|
||||
'Warmup complete (data hot-reload watchers started, disk usage preloading)',
|
||||
);
|
||||
} catch (err) {
|
||||
fastify.log.warn({ err }, 'Warmup failed');
|
||||
|
||||
Reference in New Issue
Block a user