Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/Particular.PlatformSample/AppLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,31 @@ sealed class AppLauncher(bool showPlatformToolConsoleOutput) : IAsyncDisposable
readonly bool hideConsoleOutput = !showPlatformToolConsoleOutput;
readonly Stack<Func<ValueTask>> cleanupActions = new();

public Task<Uri> RavenDB(string logsPath, string dataDirectory, CancellationToken cancellationToken = default)
public async Task<Uri> RavenDB(string logsPath, string dataDirectory, CancellationToken cancellationToken = default)
{
var licenseFilePath = Path.Combine(platformPath, "servicecontrol", "servicecontrol-instance", "Persisters", "RavenDB", "RavenLicense.json");

var options = new ServerOptions
{
LogsPath = logsPath,
DataDirectory = dataDirectory,
CommandLineArgs = [$"--License.Path=\"{licenseFilePath}\""]
CommandLineArgs = [$"--License.Path=\"{licenseFilePath}\""],
FrameworkVersion = null
};

var currentRollforward = Environment.GetEnvironmentVariable("DOTNET_ROLL_FORWARD");

// Make RavenDB roll forward to the next available higher major version if the one it was built against is not installed
Environment.SetEnvironmentVariable("DOTNET_ROLL_FORWARD", "Major");

EmbeddedServer.Instance.StartServer(options);
cleanupActions.Push(() => StopRavenDB(cancellationToken));

return EmbeddedServer.Instance.GetServerUriAsync(cancellationToken);
var result = await EmbeddedServer.Instance.GetServerUriAsync(cancellationToken).ConfigureAwait(false);

Environment.SetEnvironmentVariable("DOTNET_ROLL_FORWARD", currentRollforward);

return result;
}

static async ValueTask StopRavenDB(CancellationToken cancellationToken)
Expand Down