Ejemplo n.º 1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (!env.IsProduction())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseCors(policy => policy.WithOrigins("https://localhost:44328").AllowAnyMethod().AllowAnyHeader().AllowCredentials());
            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseSignalR(routes =>
            {
                routes.MapHub <NotificationHub>("/notification");
            });

            HealthCheckHelper.Setup(app);
            BeatPulseHelper.Setup(app);
            SwaggerHelper.Setup(app);

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <HealthCheck> > Get(int id)
        {
            try
            {
                FileHelper        fh         = new FileHelper();
                HealthCheckHelper helthCheck = new HealthCheckHelper();

                var urlsListTasks = await fh.GetUrlsFromFilesAsync();

                var taskList = new List <Task <HealthCheck> >();
                foreach (var myRequest in urlsListTasks)
                {
                    int counter = 0;
                    // by virtue of not awaiting each call, you've already acheived parallelism
                    taskList.Add(helthCheck.HitEndpointAsync(myRequest, ++counter));
                }



                //var resultList =  await helthCheck.HitEndpointAsync(urlsListTasks);
                var result = await Task.WhenAll(taskList.ToList());

                return(result);
            }
            catch (Exception)
            {
                return(new List <HealthCheck>());
            }
        }
Ejemplo n.º 3
0
        public AgentServiceRegistration Convert()
        {
            var service = new AgentServiceRegistration
            {
                ID                = AppInfoProvider.Service.Id ?? $"{AppInfoProvider.Service.Name}:{IPUtil.GetHostName()}",
                Name              = AppInfoProvider.Service.Name,
                Tags              = AppInfoProvider.Service.Tags,
                Port              = AppInfoProvider.Service.Port,
                Address           = AppInfoProvider.Service.Address,
                EnableTagOverride = EnableTagOverride
            };

            if (Check == null)
            {
                Check = new HealthCheckSetting
                {
                    HTTP = HealthCheckHelper.GetHttpHealthUrl()
                };
            }
            service.Check = new AgentServiceCheck {
                TCP     = Check.TCP,
                Timeout = TimeSpan.FromSeconds(Check.Timeout ?? DefaultTime),
                DeregisterCriticalServiceAfter = TimeSpan.FromMinutes(Check.DeregisterCriticalServiceAfter ?? DefaultTime),
                Interval      = TimeSpan.FromSeconds(Check.Interval ?? DefaultTime),
                TLSSkipVerify = Check.TLSSkipVerify,
                HTTP          = Check.HTTP,
            };
            return(service);
        }
Ejemplo n.º 4
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (!env.IsProduction())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            HealthCheckHelper.Setup(app);
            BeatPulseHelper.Setup(app);
            SwaggerHelper.Setup(app);

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Ejemplo n.º 5
0
 private void ConfigureHelpers(IServiceCollection services)
 {
     HelpersManager.Configure(_correlationId, services, Configuration);
     CommonPatterns.Filters.ExceptionFilter.Configure(services);
     CommonPatterns.Filters.RequestResponseFilter.Configure(services);
     SwaggerHelper.Configure(services);
     CacheHelper.Configure(services);
     HealthCheckHelper.Configure(services);
     BeatPulseHelper.Configure(services, Configuration);
     WhoIsHelper.Configure(services);
 }
Ejemplo n.º 6
0
 private void HelperInjections(IServiceCollection services)
 {
     HelpersManager.Configure(_correlationId, services, Configuration);
     ExceptionFilter.Configure(services);
     RequestResponseFilter.Configure(services);
     RefreshRobotCacheFilter.Configure(services);
     RefreshCyborgCacheFilter.Configure(services);
     SwaggerHelper.Configure(services);
     CacheHelper.Configure(services);
     HealthCheckHelper.Configure(services);
     BeatPulseHelper.Configure(services, Configuration);
     WhoIsHelper.Configure(services);
 }
Ejemplo n.º 7
0
        public IActionResult HealthCheck()
        {
            try
            {
                var healthCheck = HealthCheckHelper.GetGetHostNameAndIPAddress();

                _logger.LogInformation($"{JsonConvert.SerializeObject(healthCheck)}");

                return(Ok(healthCheck));
            }
            catch (Exception exception)
            {
                _logger.LogError(exception, exception.ToLogString(Environment.StackTrace));
                return(new StatusCodeResult(500));
            }
        }
Ejemplo n.º 8
0
        public async Task <IEnumerable <HealthCheck> > Get()
        {
            try
            {
                FileHelper        fh         = new FileHelper();
                HealthCheckHelper helthCheck = new HealthCheckHelper();

                var urlsListTasks = await fh.GetUrlsFromFilesAsync();


                //var resultList =  await helthCheck.HitEndpointAsync(urlsListTasks);
                var result = await helthCheck.HitEndpointAsync(urlsListTasks);

                return(result);
            }
            catch (Exception)
            {
                return(new List <HealthCheck>());
            }
        }
Ejemplo n.º 9
0
        public IHttpActionResult Get()
        {
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();

            var entries = new Dictionary <string, HealthReportEntry>();

            entries.Add("DI Controllers", HealthCheckHelper.TestaControllersInjection("HealthCheck.API", IoC.Container));

            stopwatch.Stop();

            var response = UIHealthReport.CreateFrom(
                new HealthReport(entries, TimeSpan.FromMilliseconds(stopwatch.ElapsedMilliseconds)));

            if (response.Status == UIHealthStatus.Healthy)
            {
                return(Ok(response));
            }
            else
            {
                return(Content((System.Net.HttpStatusCode) 418, response));
            }
        }