protected internal void RefreshInstanceInfo() { InstanceInfo info = _appInfoManager.InstanceInfo; if (info == null) { return; } _appInfoManager.RefreshLeaseInfo(); InstanceStatus status = InstanceStatus.UNKNOWN; if (HealthCheckHandler != null) { try { status = HealthCheckHandler.GetStatus(info.Status); } catch (Exception e) { _logger?.LogError( "RefreshInstanceInfo HealthCheck handler exception: {0}, App: {1}, Instance: {2} marked DOWN", e, info.AppName, info.InstanceId); status = InstanceStatus.DOWN; } } if (status != InstanceStatus.UNKNOWN) { info.Status = status; } }
public IActionResult Check() { JsonResult result = null; using (HealthCheckHandler handler = new HealthCheckHandler(_settings, _eventHub, _preingestCollection)) { handler.Execute(); System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); DateTime buildDate = LinkerHelper.GetLinkerTimestampUtc(assembly); result = new JsonResult(new { ProductName = fvi.ProductName, ProductVersion = fvi.ProductVersion, BuildDateTime = DateTimeOffset.FromFileTime(buildDate.ToFileTime()), Title = "Underlying services health check.", CreationTimestamp = DateTimeOffset.Now, ActionName = typeof(HealthCheckHandler).Name, Messages = new string[] { "preingest: available", String.Format("clamav: {0}", handler.IsAliveClamAv ? "available" : "not available"), String.Format("xslweb: {0}", handler.IsAliveXslWeb ? "available" : "not available"), String.Format("droid: {0}", handler.IsAliveDroid ? "available" : "not available"), String.Format("database: {0}", handler.IsAliveDatabase ? "available" : "not available") } }); } return(result); }
public static HealthChecksBuilder AddHealthChecks(this HttpConfiguration httpConfiguration, string healthEndpoint = "health") { System.Diagnostics.Debug.WriteLine("Iniciei"); // ToDo: Era para isso estar aqui mesmo? var healthChecksBuilder = new HealthChecksBuilder(); var healthChecksService = new HealthCheckService(healthChecksBuilder); var authenticationService = new AuthenticationService(healthChecksBuilder); var dependencyHandler = new DependencyHandler(httpConfiguration, healthChecksBuilder); var authenticationHandler = new AuthenticationHandler(authenticationService); var healthCheckHandler = new HealthCheckHandler(healthChecksService); dependencyHandler.SetNextHandler(authenticationHandler); authenticationHandler.SetNextHandler(healthCheckHandler); httpConfiguration.Routes.MapHttpRoute( name: "health_check", routeTemplate: healthEndpoint, defaults: new { check = RouteParameter.Optional }, constraints: null, handler: dependencyHandler ); return(healthChecksBuilder); }
public static HealthChecksBuilder AddHealthChecks(this HttpConfiguration httpConfiguration, string healthEndpoint = "health") { var hcBuilder = new HealthChecksBuilder(); var dependencyResolver = httpConfiguration.DependencyResolver; var hcConfig = hcBuilder.HealthCheckConfig; // Service Instances var healthChecksService = new HealthCheckService(dependencyResolver, hcConfig.HealthChecksDependencies); var authenticationService = new AuthenticationService(hcConfig); // Handler Instances var authenticationHandler = new AuthenticationHandler(hcConfig, authenticationService); var healthCheckHandler = new HealthCheckHandler(hcConfig, healthChecksService); // ChainOfResponsibility authenticationHandler.SetNextHandler(healthCheckHandler); httpConfiguration.Routes.MapHttpRoute( name: "health_check", routeTemplate: healthEndpoint, defaults: new { check = RouteParameter.Optional }, constraints: null, handler: authenticationHandler ); return(hcBuilder); }
public static HealthChecksBuilder AddHealthChecks(this HttpConfiguration httpConfiguration, string healthEndpoint = "health") { var healthChecksBuilder = new HealthChecksBuilder(); var authenticationHandler = new AuthenticationHandler(httpConfiguration, healthChecksBuilder); var healthCheckHandler = new HealthCheckHandler(httpConfiguration, healthChecksBuilder); authenticationHandler.SetNextHandler(healthCheckHandler); httpConfiguration.Routes.MapHttpRoute( name: "health_check", routeTemplate: healthEndpoint, defaults: new { check = RouteParameter.Optional }, constraints: null, handler: authenticationHandler ); return(healthChecksBuilder); }
protected internal void RefreshInstanceInfo() { var info = _appInfoManager.InstanceInfo; if (info == null) { return; } _appInfoManager.RefreshLeaseInfo(); InstanceStatus?status = null; if (IsHealthCheckHandlerEnabled()) { try { status = HealthCheckHandler.GetStatus(info.Status); _logger?.LogDebug("RefreshInstanceInfo called, returning {status}", status); } catch (Exception e) { _logger?.LogError( e, "RefreshInstanceInfo HealthCheck handler. App: {Application}, Instance: {Instance} marked DOWN", info.AppName, info.InstanceId); status = InstanceStatus.DOWN; } } if (status.HasValue) { _appInfoManager.InstanceStatus = status.Value; } }