Table of Contents

Namespace AppHealthMonitor

Classes

AppConfig

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

CommandHandler

Handles console command input and execution for the daemon. Provides commands for starting, stopping, restarting, querying status, and shutting down monitored applications.

ConsoleCommand

Represents a console command that can be executed by the daemon. Encapsulates command name, description, and execution logic. Validates all parameters at construction time to fail fast on misconfiguration.

DaemonOrchestrator

Orchestrates the lifecycle of application health monitors. Owns daemon-wide state (cancellation, start signal, active monitors) and pre-validates configurations at construction time.

HealthCheckerFactory

Creates IHealthChecker instances for the specified port types. Returns an empty list when no port types are configured (process-only monitoring). Logs a warning when UDP is the only configured port type, as it provides no real health signal.

HealthMonitor

Monitors the health and lifecycle of a single application process. Provides automatic restart capabilities, resource monitoring, and port health checks.

HealthMonitorStatus

Immutable snapshot of a HealthMonitor's current state for diagnostics.

TcpHealthChecker

Checks port health by attempting to establish a TCP connection. Uses a linked cancellation token to enforce timeouts without leaking timers.

UdpHealthChecker

Checks port health by attempting to send a UDP datagram.

Limitation: UDP is connectionless. A successful send only confirms the local OS accepted the datagram into the send buffer, not that the remote endpoint received it or is alive. This checker will report success even if the target application is down. For reliable health checking, prefer TCP or WebSocket. Use UDP checks only as a supplementary probe alongside other port types.

WebSocketHealthChecker

Checks port health by attempting to establish a WebSocket connection. Verifies the endpoint is functional by confirming the connection reaches Open. The close handshake is intentionally skipped; the using block disposes the socket, which is faster and equally valid for health probing.

Interfaces

IHealthChecker

Defines a contract for checking the health of a specific port type. Implementations should handle their own timeout and cleanup logic.

Enums

PortType

Specifies the type of port monitoring to perform for an application. An empty list of PortType indicates process-only monitoring.