Пример #1
0
        /// <summary>
        /// Creates the RavenDB server.
        /// </summary>
        private RavenDbServer CreateRavenDbServer()
        {
            var config = new RavenConfiguration
            {
                Port = Config.RavenHttpServerPort.GetValue(),

                AssembliesDirectory         = Path.Combine(".", "Database", "Assemblies"),
                EmbeddedFilesDirectory      = Path.Combine(".", "Database", "Files"),
                DataDirectory               = Path.Combine(".", "Database", "Data"),
                CompiledIndexCacheDirectory = Path.Combine(".", "Database", "Raven", "CompiledIndexCache"),
                PluginsDirectory            = Path.Combine(".", "Database", "Plugins"),
                MaxSecondsForTaskToWaitForDatabaseToLoad = 20,
            };

            config.Settings.Add("Raven/CompiledIndexCacheDirectory", config.CompiledIndexCacheDirectory);

            var ravenDbServer = new RavenDbServer(config);

            ravenDbServer.Initialize();

            ravenDbServer.DocumentStore.DefaultDatabase = Config.RavenName.GetValue();
            ravenDbServer.DocumentStore.DatabaseCommands.GlobalAdmin.EnsureDatabaseExists(ravenDbServer.DocumentStore.DefaultDatabase);

            ravenDbServer.FilesStore.DefaultFileSystem = Config.RavenName.GetValue();
            ravenDbServer.FilesStore.AsyncFilesCommands.Admin.EnsureFileSystemExistsAsync(ravenDbServer.FilesStore.DefaultFileSystem).Wait();

            if (Config.EnableRavenHttpServer.GetValue())
            {
                ravenDbServer.EnableHttpServer();
            }

            this.CustomizeRavenDocumentStore(ravenDbServer.DocumentStore);

            return(ravenDbServer);
        }