This commit is contained in:
31
Program.cs
31
Program.cs
@@ -1,24 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using OutputServiceTSDB.RabbitMQ;
|
||||
using Sentry;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
namespace OutputServiceTSDB
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
using (SentrySdk.Init("https://744f5d479bdb4478b386173b92d081ac@sentry.kmlabz.com/12"))
|
||||
{
|
||||
var serviceCollection = new ServiceCollection();
|
||||
ConfigureServices(serviceCollection);
|
||||
|
||||
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
RabbitMQWorker rabbitMQWorker = serviceProvider.GetService<RabbitMQWorker>();
|
||||
rabbitMQWorker.ProcessMessages();
|
||||
}
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureServices((hostContext, services) =>
|
||||
{
|
||||
services.AddHostedService<Worker>();
|
||||
});
|
||||
private static void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddLogging(configure => configure.AddConsole())
|
||||
.Configure<LoggerFilterOptions>(options => options.MinLevel = LogLevel.Information)
|
||||
.AddTransient<RabbitMQWorker>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user