Пример #1
0
        public void Start(DocumentStoreConfiguration config)
        {
            _config = config;
            BuildContainer(config);

            if (_config.EnableSingleAggregateRepositoryCache)
            {
                _logger.InfoFormat("Single Aggregate Repository Cache - ENABLED");
                JarvisFrameworkGlobalConfiguration.EnableSingleAggregateRepositoryCache();
            }
            else
            {
                _logger.InfoFormat("Single Aggregate Repository Cache - DISABLED");
                JarvisFrameworkGlobalConfiguration.DisableSingleAggregateRepositoryCache();
            }
            if (_config.DisableRepositoryLockOnAggregateId)
            {
                _logger.InfoFormat("Repository lock on Aggregate Id - DISABLED");
                NeventStoreExGlobalConfiguration.DisableRepositoryLockOnAggregateId();
            }
            else
            {
                _logger.InfoFormat("Repository lock on Aggregate Id - ENABLED");
                NeventStoreExGlobalConfiguration.EnableRepositoryLockOnAggregateId();
            }

            Manager = BuildTenants(_container, config);
            //Setup database check.
            foreach (var tenant in _config.TenantSettings)
            {
                foreach (var connection in _databaseNames)
                {
#pragma warning disable S1848 // Objects should not be created to be dropped immediately without being used
                    new DatabaseHealthCheck(
                        String.Format("Tenant: {0} [Db:{1}]", tenant.TenantId, connection),
                        tenant.GetConnectionString(connection));
#pragma warning restore S1848 // Objects should not be created to be dropped immediately without being used
                }
            }

            while (!StartupCheck())
            {
                _logger.InfoFormat("Some precondition to start the service are not met. Will retry in 3 seconds!");
                Thread.Sleep(3000);
            }

            if (RebuildSettings.ShouldRebuild && Environment.UserInteractive)
            {
                Console.WriteLine("---> Set Log Level to INFO to speedup rebuild (y/N)?");
                var res = Console.ReadLine().Trim().ToLowerInvariant();
                if (res == "y")
                {
                    SetLogLevelTo("INFO");
                }
            }

            _logger.DebugFormat(
                "Roles:\n  api: {0}\n  worker : {1}\n  projections: {2}",
                config.IsApiServer,
                config.IsWorker,
                config.IsReadmodelBuilder
                );

            InitializeEverything(config);

            //Check if container misconfigured
            _container.CheckConfiguration();
        }