From 14c64d80329a79184753e08cebe4ef6e105f800f Mon Sep 17 00:00:00 2001 From: szbk Date: Mon, 16 Feb 2026 14:47:26 +0300 Subject: [PATCH] =?UTF-8?q?feat(watcher):=20polling=20deste=C4=9Fi=20ekle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CORE_WATCHER_USE_POLLING ve CORE_WATCHER_POLL_INTERVAL_MS ortam değişkenleri eklendi. Bu değişkenler sayesinde dosya izleyici için polling modu ve aralığı yapılandırılabilir hale getirildi. --- .env.example | 2 ++ services/core/src/config/env.ts | 2 ++ services/core/src/watcher/index.ts | 12 ++++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index b848ac9..834d9e1 100644 --- a/.env.example +++ b/.env.example @@ -13,6 +13,8 @@ MEDIA_MOVIE_PATH=/media/movie ENABLE_API_KEY=false API_KEY= CORE_WATCHER_DEDUP_WINDOW_MS=15000 +CORE_WATCHER_USE_POLLING=false +CORE_WATCHER_POLL_INTERVAL_MS=2000 ENABLE_TA_STEP_LOGS=false CLAMAV_AUTO_UPDATE=true CLAMAV_FAIL_ON_UPDATE_ERROR=false diff --git a/services/core/src/config/env.ts b/services/core/src/config/env.ts index 038b6c4..6905bf1 100644 --- a/services/core/src/config/env.ts +++ b/services/core/src/config/env.ts @@ -15,5 +15,7 @@ export const env = { enableApiKey: process.env.ENABLE_API_KEY === 'true', apiKey: process.env.API_KEY ?? '', watcherDedupWindowMs: Number(process.env.CORE_WATCHER_DEDUP_WINDOW_MS ?? 15000), + watcherUsePolling: process.env.CORE_WATCHER_USE_POLLING === 'true', + watcherPollIntervalMs: Number(process.env.CORE_WATCHER_POLL_INTERVAL_MS ?? 2000), isDev: (process.env.NODE_ENV ?? 'development') !== 'production' }; diff --git a/services/core/src/watcher/index.ts b/services/core/src/watcher/index.ts index ca94841..6e353db 100644 --- a/services/core/src/watcher/index.ts +++ b/services/core/src/watcher/index.ts @@ -26,7 +26,13 @@ export async function startWatcher(): Promise { const byPath = new Map(watched.map((w) => [w.path, w.kind])); const shouldProcessEvent = createEventDeduper(env.watcherDedupWindowMs); - const watcher = chokidar.watch(paths, { ignoreInitial: false, awaitWriteFinish: false, persistent: true }); + const watcher = chokidar.watch(paths, { + ignoreInitial: false, + awaitWriteFinish: false, + persistent: true, + usePolling: env.watcherUsePolling, + interval: env.watcherPollIntervalMs + }); watcher.on('add', async (p) => { if (!isVideoFile(p)) return; @@ -51,7 +57,9 @@ export async function startWatcher(): Promise { await media.MediaFileModel.updateOne({ path: p }, { status: 'MISSING', lastSeenAt: new Date() }); }); - console.log(`[core] watcher started for: ${paths.join(', ')}`); + console.log( + `[core] watcher started for: ${paths.join(', ')} (polling=${env.watcherUsePolling ? 'on' : 'off'}, intervalMs=${env.watcherPollIntervalMs})` + ); } function resolveKind(filePath: string, byPath: Map): 'tv' | 'movie' {