Exemplo n.º 1
0
        public static HealthChecksUiSettings AddHealthCheckEndpoints(this HealthChecksUiSettings settings, AcuWebSites websites)
        {
            foreach (var website in websites ?? new AcuWebSites())
            {
                settings.AddHealthCheckEndpoint(website.Name, website.EndpointUrl);
            }

            return(settings);
        }
Exemplo n.º 2
0
 public static void AddHealthCheckEndpointIfExists(this HealthChecks.UI.Configuration.Settings setup, string name, string uri)
 {
     if (!string.IsNullOrEmpty(uri))
     {
         try
         {
             setup.AddHealthCheckEndpoint(name, uri);
         }
         catch (Exception)
         {
         }
     }
 }
Exemplo n.º 3
0
        internal static HealthChecks.UI.Configuration.Settings AddIoTSharpHealthCheckEndpoint(this HealthChecks.UI.Configuration.Settings setup)
        {
            var urls = Environment.GetEnvironmentVariable("ASPNETCORE_URLS")?.Split(';');
            var uris = urls?.Select(url => Regex.Replace(url, @"^(?<scheme>https?):\/\/((\+)|(\*)|(0.0.0.0))(?=[\:\/]|$)", "${scheme}://localhost"))
                       .Select(uri => new Uri(uri, UriKind.Absolute)).ToArray();
            var httpEndpoint  = uris?.FirstOrDefault(uri => uri.Scheme == "http");
            var httpsEndpoint = uris?.FirstOrDefault(uri => uri.Scheme == "https");

            if (httpEndpoint != null) // Create an HTTP healthcheck endpoint
            {
                setup.AddHealthCheckEndpoint("IoTSharp", new UriBuilder(httpEndpoint.Scheme, httpEndpoint.Host, httpEndpoint.Port, "/healthz").ToString());
            }
            else if (httpsEndpoint != null) // Create an HTTPS healthcheck endpoint
            {
                setup.AddHealthCheckEndpoint("IoTSharp", new UriBuilder(httpsEndpoint.Scheme, httpsEndpoint.Host, httpsEndpoint.Port, "/healthz").ToString());
            }
            else
            {
                //One endpoint is configured in appsettings, let's add another one programatically
                setup.AddHealthCheckEndpoint("IoTSharp", "/healthz");
            }
            return(setup);
        }