mc-server-manager/agent/source/config.d

25 lines
754 B
D

module config;
/// The configuration data available in a "agent-config.properties" file in the agent's working directory.
struct AgentConfig {
const string webUrl = "http://localhost:8080";
const string discordWebhookUrl = null;
const string agentKey = "abc";
const int serverInactivityTimeoutMinutes = 30;
}
AgentConfig readConfig() {
import properd;
import std.file : exists;
if (exists("agent-config.properties")) {
auto props = readProperties("agent-config.properties");
return AgentConfig(
props["webUrl"],
props["discordWebhookUrl"],
props["agentKey"],
props.as!(int)("serverInactivityTimeoutMinutes")
);
}
throw new Exception("Missing agent-config.properties");
}