44 lines
1.2 KiB
C#
Raw Normal View History

2025-05-27 14:27:50 +08:00
namespace JiShe.IoT;
2025-05-27 14:02:24 +08:00
public class Program
{
public static async Task<int> Main(string[] args)
{
try
{
2025-08-19 14:27:24 +08:00
Log.Information("JiShe.IoT.HttpApi.Host.");
2025-05-27 14:02:24 +08:00
var builder = WebApplication.CreateBuilder(args);
builder.Host
.AddAppSettingsSecretsJson()
.UseAutofac()
.UseSerilog((context, loggerConfiguration) =>
{
SerilogToEsExtensions.SetSerilogConfiguration(
loggerConfiguration,
context.Configuration);
});
2025-05-27 14:27:50 +08:00
await builder.AddApplicationAsync<JiShe.IoT.IoTHttpApiHostModule>();
2025-07-08 16:08:03 +08:00
#if DEBUG
2025-07-08 22:24:26 +08:00
builder.WebHost.UseUrls($"http://+:10500");
2025-07-08 16:08:03 +08:00
#endif
2025-05-27 14:02:24 +08:00
var app = builder.Build();
await app.InitializeApplicationAsync();
await app.RunAsync();
return 0;
}
catch (Exception ex)
{
if (ex is HostAbortedException)
{
throw;
}
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
await Log.CloseAndFlushAsync();
}
}
}