From 8447f627bac611b7f5450a024f7f5febc9481190 Mon Sep 17 00:00:00 2001 From: Anton Popovichenko Date: Thu, 19 Aug 2021 22:26:16 +0200 Subject: Core/Config: Implement config override with env vars (#26811) * Core/Config: Implement config override with env vars Implement overriding of configuration from the .conf file with environment variables. Environment variables keys are autogenerated based on the keys defined in .conf file. Usage example: $ export TC_DATA_DIR=/usr $ TC_WORLD_SERVER_PORT=8080 ./worldserver * Core/Config Fix typo in logs Co-authored-by: Giacomo Pozzoni * Core/Config Fix code style in EnvVarForIniKey Co-authored-by: Shauren * Update tests/common/Config.cpp * Apply suggestions from code review Co-authored-by: Peter Keresztes Schmidt * Apply suggestions from code review Co-authored-by: Peter Keresztes Schmidt Co-authored-by: Anton Popovichenko Co-authored-by: Giacomo Pozzoni Co-authored-by: Shauren Co-authored-by: Peter Keresztes Schmidt (cherry picked from commit 1ddd9dc19cc1df1a1ab8c6123283999f9dea6760) --- src/server/bnetserver/Main.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/server/bnetserver/Main.cpp') diff --git a/src/server/bnetserver/Main.cpp b/src/server/bnetserver/Main.cpp index 1062233dc7d..65d04438574 100644 --- a/src/server/bnetserver/Main.cpp +++ b/src/server/bnetserver/Main.cpp @@ -113,6 +113,8 @@ int main(int argc, char** argv) return 1; } + std::vector overriddenKeys = sConfigMgr->OverrideWithEnvVariablesIfAny(); + sLog->RegisterAppender(); sLog->Initialize(nullptr); @@ -129,6 +131,9 @@ int main(int argc, char** argv) } ); + for (std::string const& key : overriddenKeys) + TC_LOG_INFO("server.authserver", "Configuration field '%s' was overridden with environment variable.", key.c_str()); + // Seed the OpenSSL's PRNG here. // That way it won't auto-seed when calling BigNumber::SetRand and slow down the first world login BigNumber seed; -- cgit v1.2.3