perf: background poller for near-instant dashboard responses
- New poller.js polls all services on a configurable interval - POLL_INTERVAL env var (default 5000ms / 5 seconds) - All data stored in cache with TTL of 3x poll interval - Dashboard endpoint now reads from cache only (no network calls) - API responses are near-instant regardless of service count - First poll runs immediately on server start
This commit is contained in:
@@ -54,6 +54,7 @@ const radarrRoutes = require('./routes/radarr');
|
||||
const embyRoutes = require('./routes/emby');
|
||||
const dashboardRoutes = require('./routes/dashboard');
|
||||
const authRoutes = require('./routes/auth');
|
||||
const { startPoller, POLL_INTERVAL } = require('./utils/poller');
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3001;
|
||||
@@ -79,5 +80,7 @@ app.listen(PORT, () => {
|
||||
console.log(` sofarr - Your Downloads Dashboard`);
|
||||
console.log(` Server running on port ${PORT}`);
|
||||
console.log(` Log level: ${process.env.LOG_LEVEL || 'info'}`);
|
||||
console.log(` Poll interval: ${POLL_INTERVAL}ms`);
|
||||
console.log(`=================================`);
|
||||
startPoller();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user