feat: owner review 2 phase 2: scheduled jobs and log settings (#10)
CI / Build and test (push) Successful in 7m0s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 13m28s
CI / PostgreSQL 16 integration (push) Successful in 5m52s
CI / PostgreSQL 17 integration (push) Successful in 4m50s
CI / Docker image (push) Successful in 1m4s
Release / Server image (push) Successful in 1m35s
CI / Build and test (push) Successful in 7m0s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 13m28s
CI / PostgreSQL 16 integration (push) Successful in 5m52s
CI / PostgreSQL 17 integration (push) Successful in 4m50s
CI / Docker image (push) Successful in 1m4s
Release / Server image (push) Successful in 1m35s
- Jobs > Scheduled on the desktop and the admin panel. Every timer that queued work is now a visible system schedule: archive scan, upload clean-up, index backup, job-history and audit clean-ups, desktop housekeeping. New actions: verify, thumbnails, proxies, analysis, maintenance, backup, clean-ups, reports. - The scheduler: migration 0007, in-house recurrence, compare-and-set claim, catch-up, scan at start. - Log settings: levels, retention, size parts, total limit, daily or hourly rotation, audit retention, diagnostics share; the server writes Debug/Trace to its files again; logging never fails a job. Upgrade: CHRONOS_LOG_LEVEL set in an existing container locks both levels; migration 0007 is one-way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #10.
This commit is contained in:
1 parent
1f089888e8
commit
af9eeaab9b
349 files changed
+28341
-1304
No files matched your search
@@ -1,19 +1,19 @@
|
||||
// Settings (BRIEF §14.8): server name, ports, TLS, discovery, jobs, limits, language, retention. 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. About (version, API, database,
|
||||
// uptime) is the last group, read-only (owner review 2); #/about opens here on it.
|
||||
// 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 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); Keep audit shows the
|
||||
// Audit log clean-up schedule's age limit (0 while it is off), and saving a new one sets it. 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";
|
||||
|
||||
/** Setting → environment variable that can fix it (BRIEF §14.9). */
|
||||
const VARIABLES = {
|
||||
serverName: "CHRONOS_SERVER_NAME", httpPort: "CHRONOS_HTTP_PORT", httpsPort: "CHRONOS_HTTPS_PORT", tlsMode: "CHRONOS_TLS_MODE",
|
||||
tlsCert: "CHRONOS_TLS_CERT", tlsKey: "CHRONOS_TLS_KEY", language: "CHRONOS_LANG", parallelism: "CHRONOS_PARALLELISM", discovery: "CHRONOS_DISCOVERY",
|
||||
priorityQueue: "CHRONOS_PRIORITY_QUEUE",
|
||||
};
|
||||
/** Levels of the priority queue, highest first. */
|
||||
const LEVELS = ["high", "normal", "low"];
|
||||
/** Log levels, least severe first (the server's wire names). */
|
||||
const LOG_LEVELS = ["trace", "debug", "information", "warning", "error", "critical", "none"];
|
||||
const ROTATIONS = ["daily", "hourly"];
|
||||
/** Settings the server names in error details whose field here has another name. */
|
||||
const FIELDS = { maxuploadbytes: "maxUploadMb", chunksizebytes: "chunkSizeMib" };
|
||||
const PEM_FILES = ["tlsCert", "tlsKey"];
|
||||
@@ -37,11 +37,19 @@ export async function render(root, { api, info, setMeta, actions }) {
|
||||
actions.innerHTML = `<button class="btn primary" type="submit" form="settings-form" data-i18n="Admin.Common.Save" data-i18n-title="Admin.Common.Save.Tip"></button>`;
|
||||
applyStrings(actions);
|
||||
|
||||
const locked = (name) => settings.locked.some((l) => l.toLowerCase() === name.toLowerCase());
|
||||
const lock = (name) => locked(name) ? `disabled title="${attr(t("Admin.Settings.Locked.Tip", VARIABLES[name] ?? name))}"` : `data-i18n-title="Admin.Settings.${cap(name)}.Tip"`;
|
||||
const same = (a, b) => a.toLowerCase() === b.toLowerCase();
|
||||
const locked = (name) => settings.locked.some((l) => same(l, name));
|
||||
// The server names the variable that fixes each locked setting: CHRONOS_LOG_LEVEL fixes the console's level too, unless
|
||||
// CHRONOS_LOG_CONSOLE_LEVEL sets its own (BRIEF §14.9).
|
||||
const variable = (name) => Object.entries(settings.lockedBy ?? {}).find(([setting]) => same(setting, name))?.[1] ?? name;
|
||||
const lock = (name) => locked(name) ? `disabled title="${attr(t("Admin.Settings.Locked.Tip", variable(name)))}"` : `data-i18n-title="Admin.Settings.${cap(name)}.Tip"`;
|
||||
const field = (name, input) => `<label class="field"><span data-i18n="Admin.Settings.${cap(name)}"></span>${input}</label>`;
|
||||
const number = (name, value, attrs = "") => field(name, `<input class="input narrow num" type="number" name="${name}" value="${attr(value)}" ${attrs} ${lock(name)}>`);
|
||||
const text = (name, value, attrs = "dir=\"auto\"") => field(name, `<input class="input" name="${name}" value="${attr(value ?? "")}" ${attrs} ${lock(name)}>`);
|
||||
// A value this page does not know stays listed, so saving the other settings never changes it.
|
||||
const choice = (name, value, values, label) => field(name, `<select class="input" name="${name}" ${lock(name)}>${values.concat(values.includes(value) ? [] : [value])
|
||||
.map((v) => `<option value="${attr(v)}" ${v === value ? "selected" : ""}>${escapeHtml(t(label(v)))}</option>`).join("")}</select>`);
|
||||
const level = (name, value) => choice(name, value, LOG_LEVELS, (l) => `Admin.Settings.Level.${cap(l)}`);
|
||||
|
||||
function draw() {
|
||||
root.innerHTML = `
|
||||
@@ -81,7 +89,17 @@ 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>
|
||||
${level("logLevel", settings.logs.fileLevel)}
|
||||
${level("consoleLogLevel", settings.logs.consoleLevel)}
|
||||
${number("logRetentionDays", settings.logs.retentionDays, 'min="1" max="3650"')}
|
||||
${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="3650"')}
|
||||
${number("diagnosticsLogMb", settings.logs.diagnosticsLogMb, 'min="1" max="1024"')}
|
||||
</section>
|
||||
</form>
|
||||
${about()}`;
|
||||
@@ -156,7 +174,16 @@ 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)),
|
||||
retentionDays: Number(value("logRetentionDays", settings.logs.retentionDays)),
|
||||
maxFileMb: Number(value("logMaxFileMb", settings.logs.maxFileMb)),
|
||||
maxTotalMb: Number(value("logMaxTotalMb", settings.logs.maxTotalMb)),
|
||||
rotation: String(value("logRotation", settings.logs.rotation)),
|
||||
auditRetentionDays: Number(value("auditRetentionDays", settings.logs.auditRetentionDays)),
|
||||
diagnosticsLogMb: Number(value("diagnosticsLogMb", settings.logs.diagnosticsLogMb)),
|
||||
},
|
||||
};
|
||||
try {
|
||||
settings = await api.put("/api/v1/server/settings", request);
|
||||
|
||||
Reference in new issue
Block a user