2022-02-17 12:36:02 +00:00
|
|
|
|
var options = new WebApplicationOptions
|
2019-08-01 08:47:15 +00:00
|
|
|
|
{
|
2022-02-17 12:36:02 +00:00
|
|
|
|
Args = args,
|
|
|
|
|
ContentRootPath = WindowsServiceHelpers.IsWindowsService() ? AppContext.BaseDirectory : default
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(options);
|
|
|
|
|
|
|
|
|
|
builder.Host.UseWindowsService();
|
|
|
|
|
builder.Host.UseSystemd();
|
|
|
|
|
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
|
|
|
|
|
2022-03-10 17:30:29 +00:00
|
|
|
|
builder.WebHost.ConfigureDefaultKestrel();
|
2021-04-23 13:54:12 +00:00
|
|
|
|
|
2022-03-10 17:30:29 +00:00
|
|
|
|
builder.Host.ConfigureDefaultAppConfiguration(args, (hostContext, config, env, path) =>
|
2022-02-17 12:36:02 +00:00
|
|
|
|
{
|
2022-03-10 17:30:29 +00:00
|
|
|
|
config.AddJsonFile($"appsettings.services.json", true)
|
|
|
|
|
.AddJsonFile("notify.json")
|
|
|
|
|
.AddJsonFile($"notify.{env.EnvironmentName}.json", true);
|
2022-02-17 12:36:02 +00:00
|
|
|
|
});
|
|
|
|
|
|
2022-03-14 09:07:37 +00:00
|
|
|
|
builder.Host.ConfigureDefaultServices((hostContext, services, diHelper) =>
|
2022-02-17 12:36:02 +00:00
|
|
|
|
{
|
2022-03-01 16:43:43 +00:00
|
|
|
|
services.AddHttpClient();
|
2022-02-11 16:01:38 +00:00
|
|
|
|
|
2022-02-17 12:36:02 +00:00
|
|
|
|
diHelper.RegisterProducts(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath);
|
|
|
|
|
services.AddHostedService<ServiceLauncher>();
|
|
|
|
|
diHelper.TryAdd<ServiceLauncher>();
|
|
|
|
|
NotifyConfigurationExtension.Register(diHelper);
|
|
|
|
|
diHelper.TryAdd<EmailSenderSink>();
|
2022-03-01 16:43:43 +00:00
|
|
|
|
services.AddAutoMapper(Assembly.GetAssembly(typeof(MappingProfile)));
|
2022-02-17 12:36:02 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
builder.Host.ConfigureNLogLogging();
|
|
|
|
|
|
|
|
|
|
var startup = new BaseWorkerStartup(builder.Configuration);
|
|
|
|
|
|
|
|
|
|
startup.ConfigureServices(builder.Services);
|
|
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
startup.Configure(app);
|
|
|
|
|
|
|
|
|
|
app.Run();
|