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

- 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:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-10-27 11:19:26 +01:00
1 parent 1f089888e8
commit af9eeaab9b
349 files changed
+28341 -1304

No files matched your search

+29 -4
View File
@@ -2,11 +2,14 @@ namespace Chronos.Protocol;
/// <summary>
/// <c>GET/PUT /api/v1/server/settings</c> (admin): the editable part of the server configuration. Settings named in
/// <see cref="Locked"/> come from environment variables and cannot be changed here; <see cref="RestartRequired"/> says
/// that saved values (ports, TLS, chunk size, job history) wait for a restart. <see cref="ProxyWarning"/> is set in
/// responses when TLS mode is proxy and the request did not come through a trusted proxy over HTTPS (ignored when saving).
/// <see cref="Locked"/> come from environment variables and cannot be changed here; <see cref="LockedBy"/> names the
/// variable that fixes each of them (ignored when saving); <see cref="RestartRequired"/> says
/// that saved values (ports, TLS, chunk size) wait for a restart; <see cref="JobHistoryDays"/> is what the housekeeping
/// schedule is reset to (owner review 2, R10). <see cref="ProxyWarning"/> is set in responses when TLS mode is proxy and
/// the request did not come through a trusted proxy over HTTPS (ignored when saving).
/// <see cref="Parallelism"/> is how many photos the running job processes at once (jobs run one at a time), and
/// <see cref="PriorityQueue"/> with <see cref="JobPriorities"/> the priority queue (owner review 1); both apply at once.
/// <see cref="PriorityQueue"/> with <see cref="JobPriorities"/> the priority queue (owner review 1); both apply at once, as
/// do <see cref="Logs"/> (owner review 2, R11; a request without them keeps them as they are).
/// </summary>
public sealed record ServerSettingsDto(
string ServerName,
@@ -25,10 +28,32 @@ public sealed record ServerSettingsDto(
int JobHistoryDays,
int TokenLifetimeDays,
int UploadRetentionHours,
LogSettingsDto Logs,
IReadOnlyList<string> Locked,
IReadOnlyDictionary<string, string> LockedBy,
bool RestartRequired,
bool ProxyWarning);
/// <summary>
/// The log settings of <see cref="ServerSettingsDto"/> (owner review 2, R11): the least severe level of the files and of the
/// console (<c>trace</c>, <c>debug</c>, <c>information</c>, <c>warning</c>, <c>error</c>, <c>critical</c>, <c>none</c>), the
/// days log files are kept, the size at which a file continues in a numbered one and the size of all of them (MB of 2²⁰
/// bytes, 0 = no limit), the rotation (<c>daily</c> or <c>hourly</c>, UTC), the days audit entries are kept (the audit
/// clean-up schedule's age limit; 0 = forever, as while that schedule is off) and the MB of the end of each log file in
/// the diagnostics zip. Their locks use the server.json names (<c>LogLevel</c>, <c>ConsoleLogLevel</c>,
/// <c>LogRetentionDays</c>, <c>LogMaxFileMb</c>, <c>LogMaxTotalMb</c>, <c>LogRotation</c>, <c>AuditRetentionDays</c>,
/// <c>DiagnosticsLogMb</c>).
/// </summary>
public sealed record LogSettingsDto(
string FileLevel,
string ConsoleLevel,
int RetentionDays,
int MaxFileMb,
int MaxTotalMb,
string Rotation,
int AuditRetentionDays,
int DiagnosticsLogMb);
/// <summary>A kind of job (<c>render</c>) and its level in the server's priority queue: <c>high</c>, <c>normal</c> or <c>low</c>.</summary>
public sealed record JobPriorityDto(string Kind, string Level);
+8 -1
View File
@@ -4,7 +4,7 @@ namespace Chronos.Protocol;
/// <summary>
/// Messages pushed on <c>WS /api/v1/events</c>. Each frame is one JSON object with a <c>type</c> discriminator:
/// jobProgress, jobState, sequenceChanged, cardEvent, nodeState.
/// jobProgress, jobState, sequenceChanged, cardEvent, nodeState, scheduleChanged.
/// </summary>
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
[JsonDerivedType(typeof(JobProgressEvent), "jobProgress")]
@@ -12,6 +12,7 @@ namespace Chronos.Protocol;
[JsonDerivedType(typeof(SequenceChangedEvent), "sequenceChanged")]
[JsonDerivedType(typeof(CardEvent), "cardEvent")]
[JsonDerivedType(typeof(NodeStateEvent), "nodeState")]
[JsonDerivedType(typeof(ScheduleChangedEvent), "scheduleChanged")]
public abstract record ServerEvent;
public sealed record JobProgressEvent(Guid JobId, long Done, long Total, double? ItemsPerSecond, double? EtaSeconds) : ServerEvent;
@@ -41,3 +42,9 @@ public static class CardImportStates
}
public sealed record NodeStateEvent(Guid NodeId, string ClientName, string State) : ServerEvent;
/// <summary>
/// A schedule of the server was created, edited, reset, deleted (<see cref="Deleted"/>) or ran, a run that queued nothing
/// included, or its next run moved (owner review 2, R10): the admin panel's Scheduled tab reads the list again.
/// </summary>
public sealed record ScheduleChangedEvent(Guid ScheduleId, bool Deleted) : ServerEvent;
+3 -1
View File
@@ -1,5 +1,6 @@
namespace Chronos.Protocol;
/// <summary>A job of the queue. <see cref="ScheduleId"/>: the schedule that queued it (owner review 2, R10), absent otherwise.</summary>
public sealed record JobDto(
Guid Id,
string Kind,
@@ -17,7 +18,8 @@ public sealed record JobDto(
string? Error,
DateTimeOffset Created,
DateTimeOffset? Started,
DateTimeOffset? Finished);
DateTimeOffset? Finished,
Guid? ScheduleId = null);
/// <summary><c>POST /api/v1/jobs</c>: kind = render, deep-analyse, proxies, thumbs, verify, scan, rebuild, maintenance…</summary>
public sealed record CreateJobRequest(string Kind, IReadOnlyList<Guid> Target, string? ParametersJson);
+9
View File
@@ -64,4 +64,13 @@ namespace Chronos.Protocol;
[JsonSerializable(typeof(List<LogFileDto>))]
[JsonSerializable(typeof(LogTailDto))]
[JsonSerializable(typeof(DashboardDto))]
[JsonSerializable(typeof(ScheduleParametersDto))]
[JsonSerializable(typeof(RecurrenceDto))]
[JsonSerializable(typeof(ScheduleDto))]
[JsonSerializable(typeof(List<ScheduleDto>))]
[JsonSerializable(typeof(ScheduleActionDto))]
[JsonSerializable(typeof(SchedulesDto))]
[JsonSerializable(typeof(CreateScheduleRequest))]
[JsonSerializable(typeof(UpdateScheduleRequest))]
[JsonSerializable(typeof(ScheduleRunDto))]
public sealed partial class ProtocolJson : JsonSerializerContext;
+97
View File
@@ -0,0 +1,97 @@
namespace Chronos.Protocol;
/// <summary>
/// The parameters of a schedule's action (owner review 2, R10), flat: each action reads its own fields, the others stay
/// null (and are not stored). <c>scan</c>: <see cref="Force"/> (full scan), <see cref="Deep"/> (background deep analysis of
/// what it indexes). <c>verify</c>: <see cref="OlderThanDays"/> (only sequences not verified for that many days; 0: any),
/// <see cref="Percent"/> (share of the archive's sequences per run, least recently verified first). <c>thumbnails</c>,
/// <c>proxies</c>: <see cref="Force"/> (make again those already made). <c>analysis</c>: <see cref="Deep"/> (deep instead of
/// light). <c>maintenance</c>: <see cref="DryRun"/>. <c>backup</c>: <see cref="Keep"/> (copies kept). <c>cleanup</c>:
/// <see cref="Steps"/> (step names) and <see cref="OlderThanDays"/> (what is older goes; 0 keeps everything).
/// <c>duplicates</c>, <c>orphans</c>: none.
/// </summary>
public sealed record ScheduleParametersDto(
int? OlderThanDays = null,
int? Percent = null,
bool? Deep = null,
bool? DryRun = null,
bool? Force = null,
IReadOnlyList<string>? Steps = null,
int? Keep = null);
/// <summary>
/// When a schedule fires, structured. <see cref="Kind"/> = <c>every</c> (<see cref="Every"/> and <see cref="Unit"/>:
/// <c>minutes</c>, <c>hours</c> or <c>days</c>; at least 5 minutes), <c>daily</c> (<see cref="Time"/>), <c>weekly</c>
/// (<see cref="Days"/>: <c>mon</c> … <c>sun</c>; <see cref="Time"/>) or <c>monthly</c> (<see cref="DayOfMonth"/> 1–28;
/// <see cref="Time"/>). <see cref="Time"/> is <c>HH:MM</c>, wall-clock time of the host's time zone.
/// </summary>
public sealed record RecurrenceDto(
string Kind,
int? Every = null,
string? Unit = null,
string? Time = null,
IReadOnlyList<string>? Days = null,
int? DayOfMonth = null);
/// <summary>
/// A schedule (owner review 2, R10). <see cref="SystemKey"/> is set on the host's system schedules (the timers it runs,
/// shown so nothing runs out of sight): they can be edited, disabled and reset, never deleted. <see cref="Priority"/> is the
/// priority of the jobs it queues (<c>background</c>, <c>normal</c>, <c>user</c>). <see cref="LastOutcome"/>:
/// <c>queued</c>, <c>skipped-pending</c>, <c>skipped-offline</c>, <c>skipped-nothing</c>, <c>unavailable</c> or
/// <c>failed:&lt;reason&gt;</c>. <see cref="NextRun"/> is null while the schedule is disabled.
/// </summary>
public sealed record ScheduleDto(
Guid Id,
string? SystemKey,
string Name,
string Action,
string Target,
ScheduleParametersDto Parameters,
RecurrenceDto Recurrence,
bool CatchUp,
string Priority,
bool Enabled,
DateTimeOffset? NextRun,
DateTimeOffset? LastRun,
Guid? LastJobId,
string? LastOutcome,
Guid? CreatedBy,
DateTimeOffset Created,
DateTimeOffset Updated);
/// <summary>An action a schedule can take and whether this host runs it; <see cref="Reason"/> says why not (a code: <c>no-handler</c>, <c>postgres</c>, <c>proxies-disabled</c>…).</summary>
public sealed record ScheduleActionDto(string Name, bool Available, string? Reason);
/// <summary>
/// <c>GET /api/v1/schedules</c>: the schedules, system ones first, the actions with their availability, the host's time
/// zone (IANA or Windows id, as the host names it) and the clean-up steps its <c>cleanup</c> action runs.
/// </summary>
public sealed record SchedulesDto(IReadOnlyList<ScheduleDto> Items, IReadOnlyList<ScheduleActionDto> Actions, string TimeZone,
IReadOnlyList<string>? Steps = null);
/// <summary><c>POST /api/v1/schedules</c>: a new schedule; <see cref="Target"/> defaults to <c>current</c>, <see cref="Priority"/> to <c>background</c>.</summary>
public sealed record CreateScheduleRequest(
string Name,
string Action,
RecurrenceDto Recurrence,
ScheduleParametersDto? Parameters = null,
bool CatchUp = true,
string? Priority = null,
bool Enabled = true,
string? Target = null);
/// <summary>
/// <c>PATCH /api/v1/schedules/{id}</c>: the fields given replace the stored ones (<see cref="Parameters"/> as a whole). A
/// system schedule keeps its name and action.
/// </summary>
public sealed record UpdateScheduleRequest(
string? Name = null,
string? Action = null,
RecurrenceDto? Recurrence = null,
ScheduleParametersDto? Parameters = null,
bool? CatchUp = null,
string? Priority = null,
bool? Enabled = null);
/// <summary><c>POST /api/v1/schedules/{id}/run</c>: what running the schedule now did, and the schedule afterwards.</summary>
public sealed record ScheduleRunDto(ScheduleDto Schedule, string Outcome, Guid? JobId);