58 lines
1.9 KiB
C#
58 lines
1.9 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Serilog;
|
|
using Serilog.Events;
|
|
using Syc.Authorize.JwtBearer;
|
|
|
|
namespace Syc.Basic.Web.WMS;
|
|
|
|
public class Program
|
|
{
|
|
public static async Task<int> Main(string[] args)
|
|
{
|
|
string logPath = AppDomain.CurrentDomain.BaseDirectory + "logs/log-.txt";
|
|
Log.Logger = new LoggerConfiguration()
|
|
#if DEBUG
|
|
.MinimumLevel.Debug()
|
|
#else
|
|
.MinimumLevel.Information()
|
|
#endif
|
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
|
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
|
|
.Enrich.FromLogContext()
|
|
.WriteTo.Async(c => c.File(logPath, rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Information))
|
|
.WriteTo.Async(c => c.Console())
|
|
.CreateLogger();
|
|
|
|
try
|
|
{
|
|
if (!HslCommunication.Authorization.SetAuthorizationCode("2fb771c7-4c29-445d-bddd-a7b8a75de397"))
|
|
{
|
|
Log.Information("HslCommunication active failed");
|
|
}
|
|
Log.Information("Starting Syc.Basic.Web.WMS.HttpApi.Host.");
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.Host.AddAppSettingsSecretsJson()
|
|
.UseAutofac()
|
|
.UseSerilog(Log.Logger);
|
|
await builder.AddApplicationAsync<WMSHttpApiHostModule>();
|
|
var app = builder.Build();
|
|
await app.InitializeApplicationAsync();
|
|
await app.RunAsync();
|
|
return 0;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Fatal(ex, "Host terminated unexpectedly!");
|
|
return 1;
|
|
}
|
|
finally
|
|
{
|
|
Log.CloseAndFlush();
|
|
}
|
|
}
|
|
} |