2021-08-01 15:22:23 -04:00
|
|
|
using Autofac.Extensions.DependencyInjection;
|
2020-01-26 01:27:45 +01:00
|
|
|
|
2020-02-12 15:16:19 +01:00
|
|
|
using PluralKit.Core;
|
|
|
|
|
2020-08-27 23:36:02 +02:00
|
|
|
using Serilog;
|
|
|
|
|
2021-11-26 21:10:56 -05:00
|
|
|
namespace PluralKit.API;
|
|
|
|
|
|
|
|
public class Program
|
2019-07-09 20:39:29 +02:00
|
|
|
{
|
2021-11-26 21:10:56 -05:00
|
|
|
public static async Task Main(string[] args)
|
2019-07-09 20:39:29 +02:00
|
|
|
{
|
2021-11-26 21:10:56 -05:00
|
|
|
InitUtils.InitStatic();
|
|
|
|
await BuildInfoService.LoadVersion();
|
2022-01-22 03:52:52 -05:00
|
|
|
var host = CreateHostBuilder(args).Build();
|
|
|
|
var config = host.Services.GetRequiredService<CoreConfig>();
|
|
|
|
await host.Services.GetRequiredService<RedisService>().InitAsync(config);
|
|
|
|
await host.RunAsync();
|
2019-07-09 20:39:29 +02:00
|
|
|
}
|
2021-11-26 21:10:56 -05:00
|
|
|
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
|
|
Host.CreateDefaultBuilder(args)
|
|
|
|
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
|
|
|
|
.UseSerilog()
|
|
|
|
.ConfigureWebHostDefaults(whb => whb
|
|
|
|
.UseConfiguration(InitUtils.BuildConfiguration(args).Build())
|
|
|
|
.ConfigureKestrel(opts =>
|
|
|
|
{
|
|
|
|
opts.ListenAnyIP(opts.ApplicationServices.GetRequiredService<ApiConfig>().Port);
|
|
|
|
})
|
|
|
|
.UseStartup<Startup>());
|
2019-07-09 20:39:29 +02:00
|
|
|
}
|