You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.7 KiB
93 lines
2.7 KiB
using LINGYUN.Abp.MicroService.ServiceDefaults;
|
|
using LINGYUN.Abp.MicroService.TaskService;
|
|
using LINGYUN.Abp.Serilog.Enrichers.Application;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Serilog;
|
|
using System;
|
|
using System.IO;
|
|
using Volo.Abp.IO;
|
|
using Volo.Abp.Modularity.PlugIns;
|
|
|
|
try
|
|
{
|
|
Log.Information("Starting TaskService Host...");
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.Host.AddAppSettingsSecretsJson()
|
|
.UseAutofac()
|
|
.ConfigureAppConfiguration((context, config) =>
|
|
{
|
|
if (context.Configuration.GetValue("AgileConfig:IsEnabled", false))
|
|
{
|
|
config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration));
|
|
}
|
|
})
|
|
.UseSerilog((context, provider, config) =>
|
|
{
|
|
config.ReadFrom.Configuration(context.Configuration);
|
|
});
|
|
|
|
builder.AddServiceDefaults();
|
|
builder.AddCustomHealthChecks<ServiceHealthCheck>("Service");
|
|
|
|
await builder.AddApplicationAsync<TaskServiceModule>(options =>
|
|
{
|
|
var applicationName = Environment.GetEnvironmentVariable("APPLICATION_NAME") ?? "TaskService";
|
|
AbpSerilogEnrichersConsts.ApplicationName = applicationName;
|
|
options.ApplicationName = applicationName;
|
|
|
|
var pluginFolder = Path.Combine(Directory.GetCurrentDirectory(), "Modules");
|
|
DirectoryHelper.CreateIfNotExists(pluginFolder);
|
|
options.PlugInSources.AddFolder(pluginFolder, SearchOption.AllDirectories);
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
await app.InitializeApplicationAsync();
|
|
|
|
app.MapDefaultEndpoints();
|
|
app.MapCustomHealthChecks("/health/service");
|
|
|
|
app.UseForwardedHeaders();
|
|
app.UseAbpRequestLocalization();
|
|
app.MapAbpStaticAssets();
|
|
app.UseCorrelationId();
|
|
app.UseRouting();
|
|
app.UseCors();
|
|
app.UseAuthentication();
|
|
app.UseJwtTokenMiddleware();
|
|
app.UseMultiTenancy();
|
|
app.UseDynamicClaims();
|
|
app.UseAuthorization();
|
|
app.UseSwagger();
|
|
app.UseAbpSwaggerUI(options =>
|
|
{
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support Task Service API");
|
|
|
|
var configuration = app.Configuration;
|
|
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
|
|
options.OAuthScopes(configuration["AuthServer:Audience"]);
|
|
});
|
|
app.UseAuditing();
|
|
app.UseAbpSerilogEnrichers();
|
|
app.UseConfiguredEndpoints();
|
|
|
|
await app.RunAsync();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (ex is HostAbortedException)
|
|
{
|
|
throw;
|
|
}
|
|
|
|
Log.Fatal(ex, "Host terminated unexpectedly!");
|
|
}
|
|
finally
|
|
{
|
|
await Log.CloseAndFlushAsync();
|
|
}
|