Refactored .NET server start

In the dev and production environment gets the .NET server started by Rust. Also, the secret IPC key gets set by using a local env variable.
This commit is contained in:
tsommer committed 2024-08-25 21:53:28 +02:00
1 parent 2e6de53095
commit 200b87f47a
2 files changed
+82 -39

No files matched your search

+15 -1
View File
@@ -11,7 +11,13 @@ using System.Reflection;
using Microsoft.Extensions.FileProviders;
#endif
var rustApiPort = args.Length > 0 ? args[0] : "5000";
if(args.Length == 0)
{
Console.WriteLine("Please provide the port of the runtime API.");
return;
}
var rustApiPort = args[0];
using var rust = new Rust(rustApiPort);
var appPort = await rust.GetAppPort();
if(appPort == 0)
@@ -20,6 +26,14 @@ if(appPort == 0)
return;
}
// Read the secret key for the IPC from the AI_STUDIO_SECRET_KEY environment variable:
var secretKey = Environment.GetEnvironmentVariable("AI_STUDIO_SECRET_KEY");
if(string.IsNullOrWhiteSpace(secretKey))
{
Console.WriteLine("The AI_STUDIO_SECRET_KEY environment variable is not set.");
return;
}
var builder = WebApplication.CreateBuilder();
builder.Services.AddMudServices(config =>
{