Healthchecks for windows services from MVC
Solution 1:
Such a health check is already available in the AspNetCore.HealthChecks.System
package. Once you add the NuGet package to your web project you can register a Windows Service health check with with AddWindowsServiceHealthCheck:
var healthBuilder=services.AddHealthChecks()
.AddSqlServer(connectionString, failureStatus: HealthStatus.Unhealthy);
foreach (ServiceController service in windowsservices)
{
healthBuilder.AddWindowsServiceHealthCheck(service.ServiceName);
}