feat(server): scheduled jobs on the server and a Scheduled tab in the admin panel

Owner review 2, R10: nothing may run out of sight, so every timer the server
ran becomes a system schedule the admin panel shows and manages, and
administrators create their own.

- SchedulerHost runs the shared Scheduler on the job engine (started after
  JobEngineHost, stopped before it); ServerScheduleHost gives it the
  container's time zone (UTC with a warning when TZ is unknown), the archive
  refreshed from archive.json at every run (what ArchivePolling did), the
  clean-up steps and the system schedules: archive-scan every 10 minutes
  (no catch-up, also run once at start like the polling), upload-cleanup
  every 30 minutes, index-backup at 03:00 (SQLite only), housekeeping (job
  history) at 04:00 and audit-cleanup at 04:30.
- ArchivePolling and DatabaseBackupService are gone; UploadMaintenance only
  recovers commits at start, its sweep is the "uploads" clean-up step.
- /api/v1/schedules (ManageArchive, audited): list with actions and time
  zone, create, PUT/PATCH, delete (409 schedule_system), run now (409
  schedule_pending), reset (409 schedule_no_defaults), runs paged by cursor;
  invalid fields are 400 invalid_schedule naming the field.
- CHRONOS_AUDIT_RETENTION_DAYS (AuditRetentionDays, default 365) seeds the
  audit clean-up; set by the environment it is applied at every start and
  locked. Job history leaves Settings: it is the housekeeping schedule's age
  limit, and the setting is what a reset restores.
- Admin panel: Jobs has Queue and Scheduled tabs; schedules with when (in
  the panel's language and the server's zone), next run, last result, a
  switch, Run now, Edit, Delete or Reset, their runs linking to the jobs, and
  a side panel for the action, recurrence and parameters; job rows a
  schedule queued carry a Scheduled pill. Strings in en and it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 808ce94ae29e3bf4522cb4d40dfd76d4f8529c64)
This commit is contained in:
Alby96 committed 2026-10-27 02:25:01 +01:00
1 parent e5508e7e69
commit 75daab7275
66 files changed
+1985 -290

No files matched your search

@@ -1,8 +1,10 @@
// Settings (BRIEF §14.8): server name, ports, TLS, discovery, jobs, limits, language, retention, logs. Values fixed by
// environment variables are read-only here; ports, TLS, chunk size and job history apply at the next restart. Jobs run one
// at a time (owner review 1): the parallelism (photos at once) and the priority queue apply at once, as do the log levels,
// retention, size limits and rotation (owner review 2, R11). About (version, API, database, uptime) is the last group,
// read-only (owner review 2); #/about opens here on it.
// environment variables are read-only here; ports, TLS and chunk size apply at the next restart. How long job history is
// kept is a parameter of the Job history clean-up schedule (Jobs › Scheduled, owner review 2, R10); the audit retention
// saved here is the Audit log clean-up schedule's age limit. Jobs run one at a time (owner review 1): the parallelism
// (photos at once) and the priority queue apply at once, as do the log levels, retention, size limits and rotation
// (owner review 2, R11). About (version, API, database, uptime) is the last group, read-only (owner review 2); #/about
// opens here on it.
import { t, applyStrings, languages } from "../i18n.js";
import { escapeHtml, attr, toast, errorText, nativeName, fingerprint, formatDuration, markInvalid, clearInvalid, invalidText, escapeReverts, routeParams, PROXY_WARNING } from "../ui.js";
import { kindLabel } from "../jobs.js";
@@ -94,7 +96,6 @@ export async function render(root, { api, info, setMeta, actions }) {
${number("chunkSizeMib", settings.chunkSizeBytes / MIB, 'min="0.0625" max="64" step="0.0625"')}
${number("tokenLifetimeDays", settings.tokenLifetimeDays, 'min="1" max="365"')}
${number("uploadRetentionHours", settings.uploadRetentionHours, 'min="1" max="8760"')}
${number("jobHistoryDays", settings.jobHistoryDays, 'min="1" max="3650"')}
</section>
<section class="panel" aria-labelledby="logs-title">
<h2 id="logs-title" data-i18n="Admin.Settings.Logs"></h2>
@@ -104,7 +105,7 @@ export async function render(root, { api, info, setMeta, actions }) {
${number("logMaxFileMb", settings.logs.maxFileMb, 'min="0" max="10240"')}
${number("logMaxTotalMb", settings.logs.maxTotalMb, 'min="0" max="1048576"')}
${choice("logRotation", settings.logs.rotation, ROTATIONS, (r) => `Admin.Settings.Rotation.${cap(r)}`)}
${number("auditRetentionDays", settings.logs.auditRetentionDays, 'min="0" max="36500"')}
${number("auditRetentionDays", settings.logs.auditRetentionDays, 'min="0" max="3650"')}
${number("diagnosticsLogMb", settings.logs.diagnosticsLogMb, 'min="1" max="1024"')}
</section>
</form>
@@ -180,7 +181,6 @@ export async function render(root, { api, info, setMeta, actions }) {
chunkSizeBytes: Math.round(Number(data.get("chunkSizeMib")) * MIB),
tokenLifetimeDays: Number(data.get("tokenLifetimeDays")),
uploadRetentionHours: Number(data.get("uploadRetentionHours")),
jobHistoryDays: Number(data.get("jobHistoryDays")),
logs: {
fileLevel: String(value("logLevel", settings.logs.fileLevel)),
consoleLevel: String(value("consoleLogLevel", settings.logs.consoleLevel)),