//===================================================================== public void InitializeGeneratedApplication(IRhetosRuntime rhetosRuntime) { // Creating a new container builder instead of using builder.Update(), because of severe performance issues with the Update method. _logger.Info("Loading generated plugins."); var stopwatch = Stopwatch.StartNew(); using (var container = rhetosRuntime.BuildContainer(_logProvider, _configuration, AddAppInitializationComponents)) { // EfMappingViewsInitializer is manually executed before other initializers because of performance issues. // It is needed for most of the initializer to run, but lazy initialization of EfMappingViews on first DbContext usage // is not a good option because of significant hash check duration (it would not be applicable in run-time). _logger.Info("Initializing EfMappingViews."); var efMappingViewsInitializer = container.Resolve <EfMappingViewsInitializer>(); efMappingViewsInitializer.Initialize(); var performanceLogger = container.Resolve <ILogProvider>().GetLogger("Performance." + GetType().Name); var initializers = ApplicationInitialization.GetSortedInitializers(container); performanceLogger.Write(stopwatch, "New modules and plugins registered."); ContainerBuilderPluginRegistration.LogRegistrationStatistics("Initializing application", container, _logProvider); if (!initializers.Any()) { _logger.Info("No server initialization plugins."); } else { foreach (var initializer in initializers) { ApplicationInitialization.ExecuteInitializer(container, initializer); } } } }
private static void InitializeGeneratedApplication(ILogger logger, DeployArguments arguments) { // Creating a new container builder instead of using builder.Update, because of severe performance issues with the Update method. Plugins.ClearCache(); logger.Trace("Loading generated plugins."); var stopwatch = Stopwatch.StartNew(); var builder = new ContainerBuilder(); builder.RegisterModule(new AutofacModuleConfiguration( deploymentTime: false, configurationArguments: arguments)); using (var container = builder.Build()) { var performanceLogger = container.Resolve<ILogProvider>().GetLogger("Performance"); var initializers = ApplicationInitialization.GetSortedInitializers(container); performanceLogger.Write(stopwatch, "DeployPackages.Program: New modules and plugins registered."); Plugins.LogRegistrationStatistics("Initializing application", container); if (!initializers.Any()) { logger.Trace("No server initialization plugins."); } else { foreach (var initializer in initializers) ApplicationInitialization.ExecuteInitializer(container, initializer); } } RestartWebServer(logger); }
//===================================================================== public void InitializeGeneratedApplication() { // Creating a new container builder instead of using builder.Update(), because of severe performance issues with the Update method. _logger.Info("Loading generated plugins."); var stopwatch = Stopwatch.StartNew(); Action <IRhetosHostBuilder> configureRhetosHost = builder => { builder.UseBuilderLogProvider(_logProvider) .ConfigureContainer(AddAppInitializationComponents); }; using (var rhetosHost = _rhetosHostFactory(configureRhetosHost)) { Type[] initializers; using (var scope = rhetosHost.CreateScope()) { // EfMappingViewsInitializer is manually executed before other initializers because of performance issues. // It is needed for most of the initializer to run, but lazy initialization of EfMappingViews on first DbContext usage // is not a good option because of significant hash check duration (it would not be applicable in run-time). _logger.Info("Initializing EfMappingViews."); var efMappingViewsInitializer = scope.Resolve <EfMappingViewsInitializer>(); efMappingViewsInitializer.Initialize(); var performanceLogger = scope.Resolve <ILogProvider>().GetLogger("Performance." + GetType().Name); initializers = ApplicationInitialization.GetSortedInitializers(scope); performanceLogger.Write(stopwatch, "New modules and plugins registered."); scope.LogRegistrationStatistics("InitializeApplication component registrations", _logProvider); scope.CommitAndClose(); } if (!initializers.Any()) { _logger.Info("No server initialization plugins."); } else { foreach (Type initializerType in initializers) { ApplicationInitialization.ExecuteInitializer(rhetosHost, initializerType, _logProvider); } } } }