// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IOptions <SuperDumpSettings> settings, IServiceProvider serviceProvider, SlackNotificationService sns, IAuthorizationHelper authorizationHelper, ILoggerFactory loggerFactory) { Task.Run(async() => await app.ApplicationServices.GetService <BundleRepository>().Populate()); Task.Run(async() => await app.ApplicationServices.GetService <RelationshipRepository>().Populate()); Task.Run(async() => await app.ApplicationServices.GetService <IdenticalDumpRepository>().Populate()); if (settings.Value.UseJiraIntegration) { Task.Run(async() => await app.ApplicationServices.GetService <JiraIssueRepository>().Populate()); } if (settings.Value.UseHttpsRedirection) { app.UseHttpsRedirection(); } app.UseStaticFiles(); app.UseRouting(); if (settings.Value.UseLdapAuthentication) { app.UseAuthentication(); app.UseAuthorization(); app.UseSwaggerAuthorizationMiddleware(authorizationHelper); } else { app.UseAuthorization(); app.MapWhen(context => context.Request.Path.StartsWithSegments("/Login") || context.Request.Path.StartsWithSegments("/api/Token"), appBuilder => appBuilder.Run(async context => { context.Response.StatusCode = 404; await context.Response.WriteAsync(""); })); } if (settings.Value.UseAllRequestLogging) { ILogger logger = loggerFactory.CreateLogger("SuperDumpServiceRequests"); app.Use(async(context, next) => { logger.LogRequest(context); await next.Invoke(); }); } app.UseHangfireDashboard("/hangfire", new DashboardOptions { Authorization = new[] { new CustomAuthorizeFilter(authorizationHelper) } }); app.UseHangfireServer(new BackgroundJobServerOptions { Queues = new[] { "download" }, WorkerCount = settings.Value.MaxConcurrentBundleExtraction }); app.UseHangfireServer(new BackgroundJobServerOptions { Queues = new[] { "analysis" }, WorkerCount = settings.Value.MaxConcurrentAnalysis }); app.UseHangfireServer(new BackgroundJobServerOptions { Queues = new[] { "elasticsearch" }, WorkerCount = 1 }); app.UseHangfireServer(new BackgroundJobServerOptions { Queues = new[] { "retention" }, WorkerCount = 1 }); app.UseHangfireServer(new BackgroundJobServerOptions { Queues = new[] { "similarityanalysis" }, WorkerCount = 8 }); if (settings.Value.UseJiraIntegration) { app.UseHangfireServer(new BackgroundJobServerOptions { Queues = new[] { "jirastatus" }, WorkerCount = 2 }); JiraIssueRepository jiraIssueRepository = app.ApplicationServices.GetService <JiraIssueRepository>(); jiraIssueRepository.StartRefreshHangfireJob(); jiraIssueRepository.StartBundleSearchHangfireJob(); } app.ApplicationServices.GetService <DumpRetentionService>().StartService(); if (settings.Value.UseAmazonSqs) { app.UseHangfireServer(new BackgroundJobServerOptions { Queues = new[] { "amazon-sqs-poll" }, WorkerCount = 2 }); AmazonSqsPollingService amazonSqsService = app.ApplicationServices.GetService <AmazonSqsPollingService>(); amazonSqsService.StartHangfireJob(); } GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 0 }); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); app.UseHealthChecks("/healthcheck"); LogProvider.SetCurrentLogProvider(new ColouredConsoleLogProvider()); if (env.EnvironmentName == "Development") { app.UseDeveloperExceptionPage(); BrowserLinkExtensions.UseBrowserLink(app); // using the extension method directly somehow did not work in .NET Core 2.0 (ambiguous extension method) } else { app.UseExceptionHandler("/Home/Error"); } app.UseWebSockets(); app.MapWebSocketManager("/cmd", serviceProvider.GetService <WebTermHandler>()); //app.UseMvcWithDefaultRoute(); //app.UseMvc(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IOptions <SuperDumpSettings> settings, IServiceProvider serviceProvider, SlackNotificationService sns, IAuthorizationHelper authorizationHelper, ILoggerFactory loggerFactory, IOneAgentSdk oneAgentSdk) { Task.Run(async() => await app.ApplicationServices.GetService <BundleRepository>().Populate()); Task.Run(async() => await app.ApplicationServices.GetService <RelationshipRepository>().Populate()); Task.Run(async() => await app.ApplicationServices.GetService <IdenticalDumpRepository>().Populate()); if (settings.Value.UseJiraIntegration) { Task.Run(async() => await app.ApplicationServices.GetService <JiraIssueRepository>().Populate()); } // configure Logger loggerFactory.AddConsole(config.GetSection("Logging")); var fileLogConfig = config.GetSection("FileLogging"); var logPath = Path.GetDirectoryName(fileLogConfig.GetValue <string>("PathFormat")); Directory.CreateDirectory(logPath); loggerFactory.AddFile(config.GetSection("FileLogging")); if (settings.Value.UseAllRequestLogging) { loggerFactory.AddFile(config.GetSection("RequestFileLogging")); } loggerFactory.AddDebug(); oneAgentSdk.SetLoggingCallback(new DynatraceSdkLogger(loggerFactory.CreateLogger <DynatraceSdkLogger>())); if (settings.Value.UseHttpsRedirection) { app.UseHttpsRedirection(); } if (settings.Value.UseLdapAuthentication) { app.UseAuthentication(); app.UseSwaggerAuthorizationMiddleware(authorizationHelper); } else { app.MapWhen(context => context.Request.Path.StartsWithSegments("/Login") || context.Request.Path.StartsWithSegments("/api/Token"), appBuilder => appBuilder.Run(async context => { context.Response.StatusCode = 404; await context.Response.WriteAsync(""); })); } if (settings.Value.UseAllRequestLogging) { ILogger logger = loggerFactory.CreateLogger("SuperDumpServiceRequests"); app.Use(async(context, next) => { logger.LogRequest(context); await next.Invoke(); }); } app.UseHangfireDashboard("/hangfire", new DashboardOptions { Authorization = new[] { new CustomAuthorizeFilter(authorizationHelper) } }); app.UseHangfireServer(new BackgroundJobServerOptions { Queues = new[] { "download" }, WorkerCount = settings.Value.MaxConcurrentBundleExtraction }); app.UseHangfireServer(new BackgroundJobServerOptions { Queues = new[] { "analysis" }, WorkerCount = settings.Value.MaxConcurrentAnalysis }); app.UseHangfireServer(new BackgroundJobServerOptions { Queues = new[] { "elasticsearch" }, WorkerCount = 1 }); app.UseHangfireServer(new BackgroundJobServerOptions { Queues = new[] { "retention" }, WorkerCount = 1 }); app.UseHangfireServer(new BackgroundJobServerOptions { Queues = new[] { "similarityanalysis" }, WorkerCount = 8 }); if (settings.Value.UseJiraIntegration) { app.UseHangfireServer(new BackgroundJobServerOptions { Queues = new[] { "jirastatus" }, WorkerCount = 2 }); JiraIssueRepository jiraIssueRepository = app.ApplicationServices.GetService <JiraIssueRepository>(); jiraIssueRepository.StartRefreshHangfireJob(); jiraIssueRepository.StartBundleSearchHangfireJob(); } app.ApplicationServices.GetService <DumpRetentionService>().StartService(); GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 0 }); app.UseSwagger(); app.UseSwaggerUi(); app.UseHealthChecks("/healthcheck"); LogProvider.SetCurrentLogProvider(new ColouredConsoleLogProvider()); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); BrowserLinkExtensions.UseBrowserLink(app); // using the extension method directly somehow did not work in .NET Core 2.0 (ambiguous extension method) } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseWebSockets(); app.MapWebSocketManager("/cmd", serviceProvider.GetService <WebTermHandler>()); app.UseMvcWithDefaultRoute(); }