Search code examples
ravendbravendb5

Run RavenDB Embedded in Memory


I haven't found in the documentation on how to do this with the Embedded server code. It recommended to use a json settings file however the documentation is clear where to put the json file or if it will work with the embedded version.


Solution

  • Configuration in RavenDB (also embedded) can be set by settings file, environment variables, and command line arguments. Command line arguments will override the settings file and those will override environment variables. The default location of the settings file is inside the binaries folder. You can change that by command line argument -c="{PATH_TO_SETTINGS_FILE}". To pass command line arguments to embedded you can use its options:

    EmbeddedServer.Instance.StartServer(new ServerOptions
    {
        CommandLineArgs = new List<string>
        {
            "-c=\"{PATH_TO_CONFIGURATION_FILE}\"",
            "LogMode=\"Information\""
        }
    });
    Console.WriteLine("started");
    

    Note: All the configurations passed by Raven.Embedded.ServerOptions are passed by the command line arguments and so will override other configuration sources for the same properties.

    https://ravendb.net/docs/article-page/5.4/csharp/server/configuration/configuration-options https://ravendb.net/docs/article-page/5.4/csharp/server/configuration/command-line-arguments https://ravendb.net/docs/article-page/5.4/csharp/server/configuration/core-configuration