示例#1
0
 private void OnInitialized(InitializeLogger msg)
 {
     Trace.WriteLine("Logging started");
     Sender.Tell(new LoggerInitialized());
 }
示例#2
0
        public void Configure(IApplicationBuilder app,
                              IStartupContext startupContext,
                              Lazy <IMainDatabase> mainDatabaseFactory,
                              Lazy <ILogDatabase> logDatabaseFactory,
                              Lazy <ICacheDatabase> cacheDatabaseFactory,
                              DatabaseTarget dbTarget,
                              ISingleInstancePolicy singleInstancePolicy,
                              InitializeLogger initializeLogger,
                              ReconfigureLogging reconfigureLogging,
                              IAppFolderFactory appFolderFactory,
                              IProvidePidFile pidFileProvider,
                              IConfigFileProvider configFileProvider,
                              IRuntimeInfo runtimeInfo,
                              IFirewallAdapter firewallAdapter,
                              ReadarrErrorPipeline errorHandler)
        {
            initializeLogger.Initialize();
            appFolderFactory.Register();
            pidFileProvider.Write();

            reconfigureLogging.Reconfigure();

            EnsureSingleInstance(false, startupContext, singleInstancePolicy);

            // instantiate the databases to initialize/migrate them
            _ = mainDatabaseFactory.Value;
            _ = logDatabaseFactory.Value;
            _ = cacheDatabaseFactory.Value;

            dbTarget.Register();

            if (OsInfo.IsNotWindows)
            {
                Console.CancelKeyPress += (sender, eventArgs) => NLog.LogManager.Configuration = null;
            }

            if (OsInfo.IsWindows && runtimeInfo.IsAdmin)
            {
                firewallAdapter.MakeAccessible();
            }

            app.UseMiddleware <LoggingMiddleware>();
            app.UsePathBase(new PathString(configFileProvider.UrlBase));
            app.UseExceptionHandler(new ExceptionHandlerOptions
            {
                AllowStatusCode404Response = true,
                ExceptionHandler           = errorHandler.HandleException
            });

            app.UseRouting();
            app.UseCors();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseResponseCompression();
            app.Properties["host.AppName"] = BuildInfo.AppName;

            app.UseMiddleware <VersionMiddleware>();
            app.UseMiddleware <UrlBaseMiddleware>(configFileProvider.UrlBase);
            app.UseMiddleware <CacheHeaderMiddleware>();
            app.UseMiddleware <IfModifiedMiddleware>();
            app.UseMiddleware <BufferingMiddleware>(new List <string> {
                "/api/v1/command"
            });

            app.UseWebSockets();

            app.UseEndpoints(x =>
            {
                x.MapHub <MessageHub>("/signalr/messages").RequireAuthorization("SignalR");
                x.MapControllers();
            });
        }
 private void ProcessMessage(InitializeLogger message)
 {
     Sender.Tell(new LoggerInitialized());
 }