diff --git a/src/FilterLists.Agent/FilterLists.Agent.csproj b/src/FilterLists.Agent/FilterLists.Agent.csproj index cf06d1dcf..3eaabe43a 100644 --- a/src/FilterLists.Agent/FilterLists.Agent.csproj +++ b/src/FilterLists.Agent/FilterLists.Agent.csproj @@ -27,17 +27,10 @@ - + + - - - - - - - - \ No newline at end of file diff --git a/src/FilterLists.Agent/Program.cs b/src/FilterLists.Agent/Program.cs index 4bdc858e2..7f1ed75e7 100644 --- a/src/FilterLists.Agent/Program.cs +++ b/src/FilterLists.Agent/Program.cs @@ -1,75 +1,9 @@ -using System; -using System.IO; -using System.Threading.Tasks; -using FilterLists.Services; -using FilterLists.Services.DependencyInjection.Extensions; -using FilterLists.Services.Extensions; -using FilterLists.Services.Snapshot; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; - -namespace FilterLists.Agent +namespace FilterLists.Agent { public static class Program { - private const int BatchSize = 1; - private static IConfigurationRoot configRoot; - private static ServiceProvider serviceProvider; - private static SnapshotService snapshotService; - private static Logger logger; - private static readonly TimeSpan Timeout = TimeSpan.FromDays(7); - - public static async Task Main() + public static void Main(string[] args) { - BuildConfigRoot(); - BuildServiceProvider(); - snapshotService = serviceProvider.GetService(); - logger = serviceProvider.GetService(); - await TryCaptureSnapshots(); - } - - private static void BuildConfigRoot() => - configRoot = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", false) - .Build(); - - private static void BuildServiceProvider() - { - var serviceCollection = new ServiceCollection(); - serviceCollection.AddFilterListsAgentServices(configRoot); - serviceProvider = serviceCollection.BuildServiceProvider(); - } - - private static async Task TryCaptureSnapshots() - { - try - { - await CaptureSnapshots(BatchSize).TimeoutAfter(Timeout); - } - catch (TimeoutException te) - { - logger.Log(te); - } - } - - private static async Task CaptureSnapshots(int batchSize) - { - logger.Log("Capturing FilterList snapshots..."); - await TryCaptureAsync(batchSize); - logger.Log("Snapshots captured."); - } - - private static async Task TryCaptureAsync(int batchSize) - { - try - { - await snapshotService.CaptureAsync(batchSize); - } - catch (Exception e) - { - logger.Log(e); - } } } } \ No newline at end of file diff --git a/src/FilterLists.Agent/appsettings.json b/src/FilterLists.Agent/appsettings.json deleted file mode 100644 index 9e5c733bb..000000000 --- a/src/FilterLists.Agent/appsettings.json +++ /dev/null @@ -1,33 +0,0 @@ -/* - WARNING - This file will be checked into source control. Do not change this file. - Use this as an example file only. - Use {env.EnvironmentName}.json as your configuration file as it will not be checked into source control. - {env.EnvironmentName} values : development, staging, production -*/ -{ - "ApplicationInsights": { - "InstrumentationKey": "" - }, - "ConnectionStrings": { - "FilterListsConnection": "" - }, - "Logging": { - "IncludeScopes": false, - "LogLevel": { - "Default": "Debug", - "System": "Information", - "Microsoft": "Information" - } - }, - "SendGrid": { - "ApiKey": "", - "From": { - "Name": "", - "EmailAddress": "" - }, - "To": { - "Name": "", - "EmailAddress": "" - } - } -} \ No newline at end of file