split scheduling into scan + process windows, move controls to settings page
Some checks failed
Build and Push Docker Image / build (push) Failing after 8s
Some checks failed
Build and Push Docker Image / build (push) Failing after 8s
the old one-window scheduler gated only the job queue. now the scan loop and the processing queue have independent windows — useful when the container runs as an always-on service and we only want to hammer jellyfin + ffmpeg at night. config keys renamed from schedule_* to scan_schedule_* / process_schedule_*, plus the existing job_sleep_seconds. scheduler.ts exposes parallel helpers (isInScanWindow / isInProcessWindow, waitForScanWindow / waitForProcessWindow) so each caller picks its window without cross-contamination. scan.ts checks the scan window between items and emits paused/resumed sse. execute.ts keeps its per-job pause + sleep-between-jobs but now on the process window. /api/execute/scheduler moved to /api/settings/schedule. frontend: ScheduleControls popup deleted from the pipeline header, replaced with a plain Start queue button. settings page grows a Schedule section with both windows and the job sleep input. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { log, error as logError, warn } from "../lib/log";
|
||||
import { getAllItems, getDevItems } from "../services/jellyfin";
|
||||
import { loadLibrary as loadRadarrLibrary, isUsable as radarrUsable } from "../services/radarr";
|
||||
import { upsertJellyfinItem } from "../services/rescan";
|
||||
import { isInScanWindow, msUntilScanWindow, nextScanWindowTime, waitForScanWindow } from "../services/scheduler";
|
||||
import { loadLibrary as loadSonarrLibrary, isUsable as sonarrUsable } from "../services/sonarr";
|
||||
|
||||
const app = new Hono();
|
||||
@@ -209,6 +210,19 @@ async function runScan(limit: number | null = null): Promise<void> {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Honour the scan window between items so overnight-only setups don't hog
|
||||
// Jellyfin during the day. Checked between items rather than mid-item so
|
||||
// we don't leave a partial upsert sitting in flight.
|
||||
if (!isInScanWindow()) {
|
||||
emitSse("paused", {
|
||||
until: nextScanWindowTime(),
|
||||
seconds: Math.round(msUntilScanWindow() / 1000),
|
||||
});
|
||||
await waitForScanWindow();
|
||||
if (signal.aborted) break;
|
||||
emitSse("resumed", {});
|
||||
}
|
||||
|
||||
processed++;
|
||||
emitSse("progress", { scanned: processed, total, current_item: jellyfinItem.Name, errors, running: true });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user