mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-08-16 21:31:45 +02:00
.config
.run
.workdir
Agent
Common
Docker
Server
Phantom.Server
AgentTokenFile.cs
CertificateFiles.cs
Phantom.Server.csproj
Program.cs
Variables.cs
WebConfigurator.cs
Phantom.Server.Database
Phantom.Server.Database.Postgres
Phantom.Server.Rpc
Phantom.Server.Services
Phantom.Server.Web
Phantom.Server.Web.Bootstrap
Phantom.Server.Web.Components
Utils
.gitattributes
.gitignore
AddMigration.bat
AddMigration.sh
PhantomPanel.sln
global.json
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using Npgsql;
|
|
using Phantom.Common.Logging;
|
|
using Phantom.Utils.Runtime;
|
|
|
|
namespace Phantom.Server;
|
|
|
|
sealed record Variables(
|
|
string WebServerHost,
|
|
ushort WebServerPort,
|
|
string RpcServerHost,
|
|
ushort RpcServerPort,
|
|
string SqlConnectionString
|
|
) {
|
|
private static Variables LoadOrThrow() {
|
|
var connectionStringBuilder = new NpgsqlConnectionStringBuilder {
|
|
Host = EnvironmentVariables.GetString("PG_HOST").OrThrow,
|
|
Port = EnvironmentVariables.GetPortNumber("PG_PORT").OrThrow,
|
|
Username = EnvironmentVariables.GetString("PG_USER").OrThrow,
|
|
Password = EnvironmentVariables.GetString("PG_PASS").OrThrow,
|
|
Database = EnvironmentVariables.GetString("PG_DATABASE").OrThrow
|
|
};
|
|
|
|
return new Variables(
|
|
EnvironmentVariables.GetString("WEB_SERVER_HOST").OrDefault("0.0.0.0"),
|
|
EnvironmentVariables.GetPortNumber("WEB_SERVER_PORT").OrDefault(9400),
|
|
EnvironmentVariables.GetString("RPC_SERVER_HOST").OrDefault("0.0.0.0"),
|
|
EnvironmentVariables.GetPortNumber("RPC_SERVER_PORT").OrDefault(9401),
|
|
connectionStringBuilder.ToString()
|
|
);
|
|
}
|
|
|
|
public static Variables LoadOrExit() {
|
|
try {
|
|
return LoadOrThrow();
|
|
} catch (Exception e) {
|
|
PhantomLogger.Root.Fatal(e.Message);
|
|
Environment.Exit(1);
|
|
throw;
|
|
}
|
|
}
|
|
}
|