Files
Ayay/SHH.ProcessLaunchers/ProcessConfig.cs

107 lines
4.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections.Generic;
namespace SHH.ProcessLaunchers
{
/// <summary>
/// 进程启动配置项
/// </summary>
public class ProcessConfig
{
#region --- (Identity) ---
// <summary>
/// [核心变更] 唯一标识符 (Key)
/// <para>用于管理器内部索引,不可重复。例如: "Streamer_01", "Streamer_02"</para>
/// </summary>
public string Id { get; set; } = string.Empty;
/// <summary>
/// [核心变更] 通用显示名称 (Category/Type)
/// <para>描述这是一类什么程序。例如: "VideoStreamingService"</para>
/// <para>多个实例可以拥有相同的 DisplayName。</para>
/// </summary>
public string DisplayName { get; set; } = string.Empty;
/// <summary>
/// 描述备注 (可选)
/// <para>例如: "负责处理 192.168.1.10 的视频流"</para>
/// </summary>
public string Description { get; set; } = string.Empty;
#endregion
#region --- (Launch Args) ---
/// <summary>可执行文件路径 (绝对路径或相对路径)</summary>
public string ExePath { get; set; } = string.Empty;
/// <summary>启动参数字符串 (例如 "--id=1 --debug")</summary>
public string Arguments { get; set; } = string.Empty;
/// <summary>工作目录 (默认为 Exe 所在目录)</summary>
public string WorkingDirectory { get; set; } = string.Empty;
#endregion
#region --- ---
/// <summary>
/// 是否显示程序窗口
/// <para>True: 弹出控制台窗口或UI | False: 后台静默运行 (CreateNoWindow=true)</para>
/// </summary>
public bool Visible { get; set; } = false;
/// <summary>
/// 是否接管标准输出/错误流 (RedirectStandardOutput)
/// <para>True: 启动器将捕获 Console.WriteLine 内容并通过日志接口转发。</para>
/// <para>注意: 如果 Visible=true建议设为 false否则控制台窗口将是黑屏。</para>
/// </summary>
public bool EnableLogRedirect { get; set; } = true;
#endregion
#region --- ---
/// <summary>意外退出后的常规重启延迟 (毫秒),默认 3000ms</summary>
public int RestartDelayMs { get; set; } = 3000;
/// <summary>连续失败阈值 (达到此次数后触发熔断),默认 3 次</summary>
public int MaxConsecutiveFailures { get; set; } = 3;
/// <summary>熔断冷却时长 (毫秒),默认 30分钟 (1800000ms)</summary>
public int CircuitBreakerDelayMs { get; set; } = 30 * 60 * 1000;
/// <summary>
/// 稳定运行判定阈值 (毫秒)
/// <para>如果进程存活时间超过此值,则视为启动成功,重置失败计数器。</para>
/// </summary>
public int StabilityThresholdMs { get; set; } = 60 * 1000;
/// <summary>
/// 自动重启间隔 (分钟)。0 表示不启用定时重启。
/// <para>用于防止内存碎片或长期运行的不稳定性。</para>
/// </summary>
public int AutoRestartIntervalMinutes { get; set; } = 0;
#endregion
#region --- ---
/// <summary>
/// [新增] 启动顺序权重
/// <para>数字越小越先启动 (0, 1, 2...)</para>
/// </summary>
public int StartupOrder { get; set; } = 0;
/// <summary>
/// [新增] 启动后等待时长 (毫秒)
/// <para>当前进程启动后,等待多久再启动下一个进程。用于防止瞬间 CPU 峰值或依赖等待。</para>
/// </summary>
public int PostStartupDelayMs { get; set; } = 3000;
#endregion
/// <summary>资源哨兵列表 (内存监控、心跳监控等)</summary>
public List<IResourceGuard> Guards { get; set; } = new List<IResourceGuard>();
}
}