feat: Chronos Desktop shares its library on the LAN (owner review 5 P4)
Chronos Server for Windows is replaced by Settings > Server > Share this library: Chronos Desktop hosts the server engine in its own process over its own index, archive and processing services, job engine and scheduler, so a second PC, the Uploader and render nodes use this PC's library without a Windows service or a second index. - Chronos.Server is a library; Chronos.Server.Host is the console exe that Docker and development runs start. The App references the library and the ASP.NET Core shared framework (no package). - ServerHost.BuildHosted/HostedServer: reuses the desktop's engines and never creates, starts or disposes them; no static log sink, no console lifetime; server.json plus desktop-owned values locked "Set in Chronos Desktop"; only upload-cleanup and audit-cleanup schedules are added. - Both modes: by-id endpoints scoped to the served archive, a client's render export folder dropped; hosted mode exposes server job kinds only. - Desktop: LibraryShare (start after the schedules, stop first, port in use named), Settings > Server sharing rows, Server > This library panel (state, addresses with Copy, ports, fingerprint, temporary admin password, clients, admin panel), own library refused by ConnectFlow and dropped from LAN discovery, the uploads sweep step, thumbnails after scans while sharing, capture scenes server-share and server-share-failed. - Removed: the Windows service hosting of Chronos.Server, its switches and its tests. Refs #67 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9ad8c6f7a9
commit
8d41992d84
69 files changed
+2633
-859
No files matched your search
@@ -74,6 +74,7 @@ public sealed class AppServices : IAsyncDisposable
|
||||
// The editor's open and closed groups survive a restart (owner review 1, R3).
|
||||
Chronos.App.Editor.EditorSettings.Groups.Bind(settings.EditorGroups, saveSettings);
|
||||
_renderNode = new RenderNodeHost(StartRenderNode);
|
||||
Share = new LibraryShare(this);
|
||||
ArchiveSetup = new EngineArchiveSetup(this);
|
||||
Sync = new SyncHost(this);
|
||||
ScheduleHost = new DesktopScheduleHost(settings, () => Database, () => Archives);
|
||||
@@ -114,6 +115,7 @@ public sealed class AppServices : IAsyncDisposable
|
||||
{
|
||||
if (_server is not null) _server.PropertyChanged -= OnServerChanged;
|
||||
_server = value;
|
||||
_server.IsOwnLibrary = Share.IsOwn;
|
||||
_server.PropertyChanged += OnServerChanged;
|
||||
UpdateRenderNode();
|
||||
Sync.Update();
|
||||
@@ -123,6 +125,9 @@ public sealed class AppServices : IAsyncDisposable
|
||||
/// <summary>Sync with the signed-in server: engine, job connection, background comparison.</summary>
|
||||
public SyncHost Sync { get; }
|
||||
|
||||
/// <summary>Settings › Server › Share this library: this PC's library served to the LAN while Chronos runs (owner review 5, #67).</summary>
|
||||
public LibraryShare Share { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A job of this PC moved a sequence's folder or changed its title or file names (a Reorganize step), or replaced its
|
||||
/// frames' files (a conversion), with the sequence's id (any thread): an open editor reads it again where and as it is now.
|
||||
@@ -239,6 +244,7 @@ public sealed class AppServices : IAsyncDisposable
|
||||
SaveSettingsAction();
|
||||
UpdateRenderNode();
|
||||
ApplyJobSettings();
|
||||
if (!Environment.IsCapture) Share.Apply();
|
||||
}
|
||||
|
||||
/// <summary>Writes the settings file and nothing else: for choices that change only what is shown (the rail, the sequence edited last).</summary>
|
||||
@@ -329,6 +335,8 @@ public sealed class AppServices : IAsyncDisposable
|
||||
{
|
||||
await _stopping.CancelAsync().ConfigureAwait(false);
|
||||
await _schedules.ConfigureAwait(false);
|
||||
// First: the shared library's clients and its subscriptions to the engine and the scheduler go before they do.
|
||||
await Share.DisposeAsync().ConfigureAwait(false);
|
||||
_schedulerReady.TrySetResult(false);
|
||||
if (Scheduler is not null) await Scheduler.DisposeAsync().ConfigureAwait(false);
|
||||
_stopping.Dispose();
|
||||
@@ -361,6 +369,7 @@ public sealed class AppServices : IAsyncDisposable
|
||||
await StartSchedulerAsync(ct).ConfigureAwait(false);
|
||||
if (reopen is null)
|
||||
{
|
||||
await Share.StartAsync(ct).ConfigureAwait(false);
|
||||
await ScanNowAsync(started, ct).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
@@ -369,6 +378,7 @@ public sealed class AppServices : IAsyncDisposable
|
||||
{
|
||||
if (!string.Equals(reopen, Settings.LastArchivePath, StringComparison.OrdinalIgnoreCase)) return;
|
||||
if (!await ReopenAsync(reopen, ct).ConfigureAwait(false)) continue;
|
||||
await Share.StartAsync(ct).ConfigureAwait(false);
|
||||
await ScanNowAsync(null, ct).ConfigureAwait(false);
|
||||
Scheduler?.Wake();
|
||||
return;
|
||||
@@ -559,19 +569,24 @@ public sealed class AppServices : IAsyncDisposable
|
||||
MemoryBudget = () => ProcessingTuning.MemoryBudget(Settings, GC.GetGCMemoryInfo().TotalAvailableMemoryBytes),
|
||||
// The housekeeping schedule trims the cache to Settings › Storage › Cache limit (owner review 2, R10).
|
||||
// The workspace-cleanup schedule removes the media past Settings › Workspace's Clean after and Size limit, and reports its trash (phase 5c).
|
||||
// The shared library's upload-cleanup schedule runs on this PC's scheduler (owner review 5, #67).
|
||||
CleanupSteps = [new CacheTrimStep(() => CacheStore.Folder(Environment, Settings), () => Settings.CacheLimitGb * (1L << 30)),
|
||||
new WorkspaceCleanStep(() => Workspace), new WorkspaceTrashStep(() => Workspace)],
|
||||
new WorkspaceCleanStep(() => Workspace), new WorkspaceTrashStep(() => Workspace), new ShareUploadsStep(() => Share)],
|
||||
BackupDirectory = Environment.BackupDirectory,
|
||||
// Told after each step of a Reorganize, and each sequence a conversion replaced or made, while the rest of the job runs.
|
||||
SequenceChanged = (id, _, _) =>
|
||||
// While the library is shared, its clients see thumbnails and proxies of what a scan finds, as a server's do.
|
||||
ImagesAfterScanWhen = () => Share.IsOn,
|
||||
// Told after each step of a Reorganize, and each sequence a conversion replaced or made, while the rest of the job
|
||||
// runs; the shared library's clients are told too.
|
||||
SequenceChanged = (id, change, token) =>
|
||||
{
|
||||
SequenceReorganized?.Invoke(id);
|
||||
return Task.CompletedTask;
|
||||
return Share.SequenceChangedAsync(id, change, token);
|
||||
},
|
||||
ProjectsChanged = (changed, token) => Share.ProjectsChangedAsync(changed, token),
|
||||
};
|
||||
Archives = new ArchiveService(database, archive);
|
||||
// The videos folder may not lie in the workspace either, and a copy of a server's renders downloads through its connection (phase 5).
|
||||
Archives.Videos.ProtectedFolders = () => [Workspace.Root];
|
||||
Archives.Videos.ProtectedFolders = () => [Workspace.Root, Share.Folder];
|
||||
Archives.Videos.Servers = Sync;
|
||||
Processing = new ProcessingService(database, ProcessingOptions(archive));
|
||||
Sync.Open(database, Archives, archive);
|
||||
@@ -602,6 +617,8 @@ public sealed class AppServices : IAsyncDisposable
|
||||
AllowsHardware = presetId => AllowsHardware(Settings.HardwareEncoding, presetId),
|
||||
Host = EncoderHost.Client,
|
||||
ProducedBy = System.Environment.MachineName,
|
||||
// A render or an advice recorded on this PC reaches the shared library's clients (owner review 5, #67).
|
||||
SequenceChanged = (id, change, token) => Share.SequenceChangedAsync(id, change, token),
|
||||
Tune = basis => ProcessingTuning.Apply(basis, Settings, GC.GetGCMemoryInfo().TotalAvailableMemoryBytes, System.Environment.ProcessorCount,
|
||||
CacheStore.Folder(Environment, Settings)),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user