2020-10-29 16:09:56 +02:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2020-10-26 16:20:47 +02:00
|
|
|
using System.Threading.Tasks;
|
2020-10-30 11:20:08 +02:00
|
|
|
using Hangfire;
|
|
|
|
using Hangfire.MemoryStorage;
|
2020-10-26 17:06:29 +02:00
|
|
|
using MalwareMultiScan.Backends.Extensions;
|
2020-10-29 16:09:56 +02:00
|
|
|
using MalwareMultiScan.Scanner.Services.Implementations;
|
2020-10-30 11:20:08 +02:00
|
|
|
using MalwareMultiScan.Scanner.Services.Interfaces;
|
2020-10-26 16:20:47 +02:00
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
|
|
|
namespace MalwareMultiScan.Scanner
|
|
|
|
{
|
2020-10-29 16:09:56 +02:00
|
|
|
[ExcludeFromCodeCoverage]
|
|
|
|
internal static class Program
|
2020-10-26 16:20:47 +02:00
|
|
|
{
|
|
|
|
public static async Task Main(string[] args)
|
|
|
|
{
|
|
|
|
await Host.CreateDefaultBuilder(args)
|
|
|
|
.ConfigureAppConfiguration(configure =>
|
|
|
|
{
|
2020-10-26 17:06:29 +02:00
|
|
|
configure.AddJsonFile("appsettings.json");
|
2020-10-26 16:20:47 +02:00
|
|
|
configure.AddEnvironmentVariables();
|
|
|
|
})
|
|
|
|
.ConfigureServices((context, services) =>
|
|
|
|
{
|
|
|
|
services.AddLogging();
|
|
|
|
|
2020-10-29 16:09:56 +02:00
|
|
|
services.AddRabbitMq(context.Configuration);
|
|
|
|
services.AddScanningBackend(context.Configuration);
|
2020-10-26 16:20:47 +02:00
|
|
|
|
2020-10-30 11:20:08 +02:00
|
|
|
services.AddSingleton<IScanBackgroundJob, ScanBackgroundJob>();
|
2020-10-26 16:20:47 +02:00
|
|
|
services.AddHostedService<ScanHostedService>();
|
2020-10-30 11:20:08 +02:00
|
|
|
|
|
|
|
services.AddHangfire(
|
|
|
|
configuration => configuration.UseMemoryStorage());
|
|
|
|
|
|
|
|
services.AddHangfireServer(options =>
|
|
|
|
{
|
|
|
|
options.WorkerCount = context.Configuration.GetValue<int>("WorkerCount");
|
|
|
|
});
|
2020-10-26 16:20:47 +02:00
|
|
|
}).RunConsoleAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|