using Elastic.CommonSchema.Serilog;
using PARR.JobAutoControl;
using PARR.JobAutoControlWorker;
using Serilog;

var builder = Host.CreateApplicationBuilder();

builder.Services.AddLogging(config =>
{
    config.ClearProviders();

    var logger = new LoggerConfiguration();

    if (builder.Environment.IsProduction())
        logger.WriteTo.Console(new EcsTextFormatter());
    else
        logger.WriteTo.Console();

    logger.ReadFrom.Configuration(builder.Configuration);

    config.AddSerilog(logger.CreateLogger());
});

builder.Services.InstallJobAutoControlServices(builder.Configuration);
builder.Configuration.AddJobAutoControlConfigurations(builder.Services);
builder.Services.AddJobAutoControlSettings(builder.Configuration);


builder.Services.AddHostedService<Worker>();

var host = builder.Build();
host.Run();






