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.
68 lines
2.4 KiB
68 lines
2.4 KiB
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 System.Threading.Tasks;
|
|
using Volo.Abp.IO;
|
|
using Volo.Abp.Modularity.PlugIns;
|
|
|
|
namespace LY.MicroService.IdentityServer;
|
|
|
|
public class Program
|
|
{
|
|
public async static Task<int> Main(string[] args)
|
|
{
|
|
try
|
|
{
|
|
Console.Title = "IdentityServer.HttpApi.Host";
|
|
Log.Information("Starting IdentityServer.HttpApi.Host.");
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.Host.AddAppSettingsSecretsJson()
|
|
.UseAutofac()
|
|
.ConfigureAppConfiguration((context, config) =>
|
|
{
|
|
var configuration = config.Build();
|
|
var agileConfigEnabled = configuration["AgileConfig:IsEnabled"];
|
|
if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled))
|
|
{
|
|
config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration));
|
|
}
|
|
})
|
|
.UseSerilog((context, provider, config) =>
|
|
{
|
|
config.ReadFrom.Configuration(context.Configuration);
|
|
});
|
|
await builder.AddApplicationAsync<IdentityServerHttpApiHostModule>(options =>
|
|
{
|
|
// 搜索 Modules 目录下所有文件作为插件
|
|
// 取消显示引用所有其他项目的模块,改为通过插件的形式引用
|
|
var pluginFolder = Path.Combine(
|
|
Directory.GetCurrentDirectory(), "Modules");
|
|
DirectoryHelper.CreateIfNotExists(pluginFolder);
|
|
options.PlugInSources.AddFolder(
|
|
pluginFolder,
|
|
SearchOption.AllDirectories);
|
|
});
|
|
var app = builder.Build();
|
|
await app.InitializeApplicationAsync();
|
|
await app.RunAsync();
|
|
return 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Fatal(ex, "Host terminated unexpectedly!");
|
|
Console.WriteLine("Host terminated unexpectedly!");
|
|
Console.WriteLine(ex.ToString());
|
|
return 1;
|
|
}
|
|
finally
|
|
{
|
|
Log.CloseAndFlush();
|
|
}
|
|
}
|
|
}
|