2025-09-10 09:05:05 +08:00
|
|
|
|
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
2025-08-19 16:44:04 +08:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2025-08-20 11:26:00 +08:00
|
|
|
|
using static Volo.Abp.Identity.Settings.IdentitySettingNames;
|
2025-08-19 16:44:04 +08:00
|
|
|
|
|
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-09-09 23:41:46 +08:00
|
|
|
|
{
|
2025-08-20 11:26:00 +08:00
|
|
|
|
//string text = Convert.ToBase64String(Encoding.UTF8.GetBytes("admin:admin123"));
|
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-08-19 16:44:04 +08:00
|
|
|
|
})
|
|
|
|
|
|
.ConfigureAppConfiguration((context, builder) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var env = context.HostingEnvironment.EnvironmentName;
|
|
|
|
|
|
Log.Information("<22><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD> <20><>" + env);
|
|
|
|
|
|
string[] filePathArray = new string[] { Environment.CurrentDirectory, "configs" };
|
|
|
|
|
|
string jsonPath = Path.Combine(filePathArray);
|
|
|
|
|
|
|
|
|
|
|
|
builder.AddJsonFile(Path.Combine(jsonPath, "appsettings.json"), false, true);
|
|
|
|
|
|
builder.AddJsonFile(Path.Combine(jsonPath, $"appsettings.{env}.json"), false, true);
|
2025-05-27 14:02:24 +08:00
|
|
|
|
});
|
2025-08-19 16:44:04 +08:00
|
|
|
|
|
2025-05-27 14:27:50 +08:00
|
|
|
|
await builder.AddApplicationAsync<JiShe.IoT.IoTHttpApiHostModule>();
|
2025-09-09 23:41:46 +08:00
|
|
|
|
builder.WebHost.ConfigureKestrel((context, options) =>
|
|
|
|
|
|
{
|
2025-09-10 09:05:05 +08:00
|
|
|
|
options.Limits.MaxRequestBodySize = 100 * 1024 * 1024; // 100MB null<6C><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-09-09 23:41:46 +08:00
|
|
|
|
options.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(2);
|
|
|
|
|
|
options.Limits.RequestHeadersTimeout = TimeSpan.FromMinutes(1);
|
2025-09-10 09:05:05 +08:00
|
|
|
|
|
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3>ֽ<EFBFBD>/<2F>룩<EFBFBD><EBA3A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪNULL<4C><4C>ʾ<EFBFBD><CABE>Ӧǿ<D3A6><C7BF>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʡ<EFBFBD>////<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3>ֽ<EFBFBD>/<2F>룩<EFBFBD><EBA3A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪNULL<4C><4C>ʾ<EFBFBD><CABE>Ӧǿ<D3A6><C7BF>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʡ<EFBFBD>
|
|
|
|
|
|
options.Limits.MinRequestBodyDataRate = null;//new MinDataRate(bytesPerSecond: 2048, gracePeriod: TimeSpan.FromSeconds(10));
|
|
|
|
|
|
|
2025-09-09 23:41:46 +08:00
|
|
|
|
});
|
2025-07-08 22:24:26 +08:00
|
|
|
|
builder.WebHost.UseUrls($"http://+:10500");
|
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();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|