Table of Contents

Class AppConfig

Namespace
AppHealthMonitor
Assembly
AppHealthMonitor.dll

Represents the configuration for a single application to be monitored. This structure mirrors the expected JSON configuration in appsettings.json.

public class AppConfig
Inheritance
AppConfig
Inherited Members

Properties

ApplicationExePath

Gets or sets the executable path. Builds/ paths resolve from the enclosing centralized build directory; other relative paths use the working directory.

public string ApplicationExePath { get; set; }

Property Value

string

CheckIntervalSeconds

Gets or sets how often to perform health checks in seconds.

public int CheckIntervalSeconds { get; set; }

Property Value

int

Remarks

Minimum enforced value: 5.

CircuitBreakerFailureThreshold

Gets or sets the consecutive failures required to trip the circuit breaker.

public int CircuitBreakerFailureThreshold { get; set; }

Property Value

int

Remarks

Minimum enforced value: 1.

CpuThresholdPercent

Gets or sets the CPU usage threshold percentage for restart (0 for no limit). Note: CPU usage is calculated using ProcessorCount, which returns logical cores (including hyperthreaded cores on Intel/AMD CPUs).

public int CpuThresholdPercent { get; set; }

Property Value

int

Enabled

Disabled entries are retained without validation or launch.

public bool Enabled { get; set; }

Property Value

bool

EnvironmentVariables

Child-only environment overrides. Do not store secrets here.

public Dictionary<string, string> EnvironmentVariables { get; set; }

Property Value

Dictionary<string, string>

ForceKillTimeoutSeconds

Gets or sets the timeout in seconds to wait for a force-killed process to exit.

public int ForceKillTimeoutSeconds { get; set; }

Property Value

int

Remarks

Minimum enforced value: 1.

GracefulShutdownTimeoutSeconds

Gets or sets the timeout for graceful shutdown in seconds.

public int GracefulShutdownTimeoutSeconds { get; set; }

Property Value

int

Remarks

Minimum enforced value: 1.

HealthCheckHost

Gets or sets the host address used for port health checks. Change to match the interface your application binds to. Defaults to "127.0.0.1" if not specified.

public string HealthCheckHost { get; set; }

Property Value

string

InitialHealthCheckDelaySeconds

Gets or sets the delay in seconds before the first full health check after launch. Allows the application time to fully initialize before being evaluated.

public int InitialHealthCheckDelaySeconds { get; set; }

Property Value

int

Remarks

Minimum enforced value: 1.

InitialRestartDelaySeconds

Gets or sets the initial delay for backoff restart in seconds.

public int InitialRestartDelaySeconds { get; set; }

Property Value

int

Remarks

Minimum enforced value: 1.

LaunchArguments

Gets or sets the optional command-line arguments for launching the application.

public string LaunchArguments { get; set; }

Property Value

string

LaunchDelaySeconds

Gets or sets the delay in seconds to wait after launching this application's monitor before launching the next one. Applied to the current application's config, not the next one. For example, setting this to 10 on App A means "wait 10s after A before launching B". Set to 0 for no delay. Not applied to the last application in the list.

public int LaunchDelaySeconds { get; set; }

Property Value

int

LaunchInTerminal

public bool LaunchInTerminal { get; set; }

Property Value

bool

MaxRestartAttempts

Gets or sets the maximum attempts for backoff restart before giving up.

public int MaxRestartAttempts { get; set; }

Property Value

int

Remarks

Minimum enforced value: 1.

MaxRestartDelaySeconds

Gets or sets the maximum delay for backoff restart in seconds.

public int MaxRestartDelaySeconds { get; set; }

Property Value

int

Remarks

Minimum enforced value: 1.

MemoryThresholdMB

Gets or sets the memory usage threshold for restart in megabytes (0 for no limit).

public int MemoryThresholdMB { get; set; }

Property Value

int

MonitoredPort

Gets or sets the port to monitor. Set to 0 for process-only monitoring.

public int MonitoredPort { get; set; }

Property Value

int

Name

Gets or sets the friendly name for the application.

public string Name { get; set; }

Property Value

string

PortCheckTimeoutMs

Gets or sets the timeout in milliseconds for TCP and UDP port health checks.

public int PortCheckTimeoutMs { get; set; }

Property Value

int

Remarks

Minimum enforced value: 1.

PortTypes

Gets or sets the health checks to run (e.g., TCP, UDP, DatabasePulse). An empty list indicates process-only monitoring with no port checks.

public List<PortType> PortTypes { get; set; }

Property Value

List<PortType>

PostLaunchSettleDelaySeconds

Gets or sets the delay in seconds to wait after launching or restarting the application before resuming health checks. Allows the process to settle.

public int PostLaunchSettleDelaySeconds { get; set; }

Property Value

int

Remarks

Minimum enforced value: 1.

PulseServerName

The name the server registers itself under, from its own ServerName setting.

public string PulseServerName { get; set; }

Property Value

string

Remarks

Defaults to Name. It is a separate setting because the daemon's name for a process and the name the server registers under are configured in different files and need not match — and matching on address or port instead would be ambiguous, since the server rows are global and two hosts can share a port number.

PulseStaleSeconds

How old a pulse may be before the server counts as down. Defaults to 90 seconds.

public int PulseStaleSeconds { get; set; }

Property Value

int

Remarks

Three missed beats at the usual 30-second interval. Too tight and a momentary database stall restarts a healthy server; too loose and a dead one lingers. If the servers' pulse interval changes, this wants changing with it.

PulseTier

Which server tier's pulse to read: login, world or scene.

public string PulseTier { get; set; }

Property Value

string

Remarks

Required when PortTypes includes DatabasePulse, and ignored otherwise.

ResourceCheckFailureThreshold

Gets or sets the number of consecutive CPU/memory check failures tolerated before triggering a restart. Prevents transient access errors (e.g., brief /proc access denial) from causing unnecessary restarts. Set to 1 for immediate restart on the first failure.

public int ResourceCheckFailureThreshold { get; set; }

Property Value

int

Remarks

Minimum enforced value: 1.

TerminalExecutable

public string TerminalExecutable { get; set; }

Property Value

string

TerminalLaunchTimeoutSeconds

public int TerminalLaunchTimeoutSeconds { get; set; }

Property Value

int

TerminalLogPath

public string TerminalLogPath { get; set; }

Property Value

string

WorkingDirectory

Defaults to the executable directory; Builds/ paths are portable.

public string WorkingDirectory { get; set; }

Property Value

string

Methods

CreateStartInfo(bool)

Resolves portable Builds/ paths from the monitor's centralized output tree. Preserves normal resolution for absolute paths and other relative paths.

public ProcessStartInfo CreateStartInfo(bool headless)

Parameters

headless bool

Returns

ProcessStartInfo

TryApplyDefaultsAndValidate(out string)

Applies sensible defaults and validates the configuration in a single step. Ensures the configuration is ready for use without requiring separate calls.

public bool TryApplyDefaultsAndValidate(out string error)

Parameters

error string

When validation fails, contains the error description.

Returns

bool

True if the configuration is valid after applying defaults; otherwise, false.