public void Configure(IApplicationBuilder app, IApplicationLifetime applicationLifetime, ILoggerFactory loggerFactory, IRabbitEndpoint rabbitEndpoint) { _rabbitEndpoint = rabbitEndpoint; applicationLifetime.ApplicationStarted.Register(OnStarted); applicationLifetime.ApplicationStopping.Register(OnShutdown); app.UseMvc(); if (Infokeeper.GetEnvironmentMode() == "dev") { loggerFactory.AddDebug(); } }
public static void Main(string[] args) { // Setup Serilog Log.Logger = new LoggerConfiguration() .MinimumLevel.Information() .WriteTo.File($"/logs/analyzer.log", rollingInterval: RollingInterval.Day) .WriteTo.Console() .CreateLogger(); // Setup DI var services = new ServiceCollection(); services.AddLogging(c => c.AddSerilog()); services.AddNodeServices(options => { }); // TODO remove and just use the ML Model! services.AddSingleton <IRabbitEndpoint, RabbitEndpoint>(); services.AddSingleton <IPipeline, RabbitClient>(); services.AddSingleton <IEngine, Engine>(); services.AddSingleton <IMediator, Mediator>(); services.AddSingleton <IMLModel, MLModel>(); services.AddSingleton <IAFINN, AFINN>(); var serviceProvider = services.BuildServiceProvider(); _rabbitEndpoint = serviceProvider.GetRequiredService <IRabbitEndpoint>(); _pipeline = serviceProvider.GetRequiredService <IPipeline>(); var engine = serviceProvider.GetRequiredService <IEngine>(); engine.Init(); // Handle cancel press and SIGTERM AssemblyLoadContext.Default.Unloading += SigTermEventHandler; Console.CancelKeyPress += CancelHandler; _rabbitEndpoint.StartListening(); _pipeline.Open(); }