|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
using HttpClientStudy.Core.Utils;
|
|
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
|
|
// Add services to the container.
|
|
|
|
|
|
|
|
|
|
builder.Services.AddControllers();
|
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
|
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
|
{
|
|
|
|
|
app.UseSwagger();
|
|
|
|
|
app.UseSwaggerUI();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
|
|
app.MapControllers();
|
|
|
|
|
|
|
|
|
|
Process currentProcess = Process.GetCurrentProcess();
|
|
|
|
|
currentProcess.EnableRaisingEvents = true;
|
|
|
|
|
currentProcess.Exited += (s, r) =>
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("000000000000000000000000000000000000");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <20><>ȡ IHostApplicationLifetime ʵ<><CAB5>
|
|
|
|
|
var applicationLifetime = app.Services.GetRequiredService<IHostApplicationLifetime>();
|
|
|
|
|
|
|
|
|
|
// ע<><D7A2>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>ر<EFBFBD><D8B1>¼<EFBFBD>
|
|
|
|
|
applicationLifetime.ApplicationStopping.Register(() =>
|
|
|
|
|
{
|
|
|
|
|
//<2F>ر<EFBFBD>WebApi
|
|
|
|
|
StartupUtility.ExitWebApiProject();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
applicationLifetime.ApplicationStopped.Register(() => {
|
|
|
|
|
Console.WriteLine("xxxxxxxxxxxxxxxxxxxx");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ע<><D7A2> AppDomain <20><>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD>¼<EFBFBD>
|
|
|
|
|
AppDomain.CurrentDomain.UnhandledException += (s,e)=>
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("<22>˳<EFBFBD>");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WebApi<70><69><EFBFBD><EFBFBD>
|
|
|
|
|
StartupUtility.StartWebApiProject();
|
|
|
|
|
|
|
|
|
|
app.Run();
|