mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-20 23:54:26 +08:00
Introduce a launcher coordinator to reserve startup ownership and prevent duplicate host launches. Adds a NamedPipe-based IPC server/client (LauncherCoordinatorIpcServer/Client), coordinator messages/models, and PublicShellStatus/activation types for richer shell reporting. Enhances StartupAttemptRecord and StartupAttemptRegistry to track coordinator pid/pipe, heartbeat, reserved-before-host-start, and public IPC status, plus new reservation/heartbeat APIs and takeover logic. Wire coordinator into App and LauncherFlowCoordinator to attach secondary launchers, publish coordinator status, probe existing hosts, and include more detailed launch result details. Also adds unit tests and docs describing coordinator and startup visuals behavior.
65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
using System.Text.Json.Serialization;
|
|
using LanMountainDesktop.Shared.Contracts.Launcher;
|
|
|
|
namespace LanMountainDesktop.Launcher.Models;
|
|
|
|
internal enum StartupAttemptState
|
|
{
|
|
Pending,
|
|
SoftTimeout,
|
|
DetachedWaiting,
|
|
Succeeded,
|
|
Failed
|
|
}
|
|
|
|
internal sealed class StartupAttemptRecord
|
|
{
|
|
[JsonPropertyName("attemptId")]
|
|
public string AttemptId { get; set; } = Guid.NewGuid().ToString("N");
|
|
|
|
[JsonPropertyName("hostPid")]
|
|
public int HostPid { get; set; }
|
|
|
|
[JsonPropertyName("coordinatorPid")]
|
|
public int CoordinatorPid { get; set; }
|
|
|
|
[JsonPropertyName("coordinatorPipeName")]
|
|
public string CoordinatorPipeName { get; set; } = string.Empty;
|
|
|
|
[JsonPropertyName("startedAtUtc")]
|
|
public DateTimeOffset StartedAtUtc { get; set; } = DateTimeOffset.UtcNow;
|
|
|
|
[JsonPropertyName("updatedAtUtc")]
|
|
public DateTimeOffset UpdatedAtUtc { get; set; } = DateTimeOffset.UtcNow;
|
|
|
|
[JsonPropertyName("heartbeatAtUtc")]
|
|
public DateTimeOffset HeartbeatAtUtc { get; set; } = DateTimeOffset.UtcNow;
|
|
|
|
[JsonPropertyName("launchSource")]
|
|
public string LaunchSource { get; set; } = string.Empty;
|
|
|
|
[JsonPropertyName("successPolicy")]
|
|
public string SuccessPolicy { get; set; } = string.Empty;
|
|
|
|
[JsonPropertyName("lastObservedStage")]
|
|
public StartupStage LastObservedStage { get; set; } = StartupStage.Initializing;
|
|
|
|
[JsonPropertyName("lastObservedMessage")]
|
|
public string LastObservedMessage { get; set; } = string.Empty;
|
|
|
|
[JsonPropertyName("ipcConnected")]
|
|
public bool IpcConnected { get; set; }
|
|
|
|
[JsonPropertyName("publicIpcConnected")]
|
|
public bool PublicIpcConnected { get; set; }
|
|
|
|
[JsonPropertyName("shellStatus")]
|
|
public string ShellStatus { get; set; } = string.Empty;
|
|
|
|
[JsonPropertyName("reservedBeforeHostStart")]
|
|
public bool ReservedBeforeHostStart { get; set; }
|
|
|
|
[JsonPropertyName("state")]
|
|
public StartupAttemptState State { get; set; } = StartupAttemptState.Pending;
|
|
}
|