feat(Core/Config): Implement config override with env vars (#16817)

* 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
$ AC_WORLD_SERVER_PORT=8080 ./worldserver

* Add tests for env vars config
This commit is contained in:
Anton Popovichenko
2023-08-14 22:07:43 +02:00
committed by GitHub
parent f633e4e9cd
commit d69ee90ed3
5 changed files with 278 additions and 6 deletions

View File

@@ -85,6 +85,8 @@ int main(int argc, char** argv)
if (!sConfigMgr->LoadAppConfigs())
return 1;
std::vector<std::string> overriddenKeys = sConfigMgr->OverrideWithEnvVariablesIfAny();
// Init logging
sLog->RegisterAppender<AppenderDB>();
sLog->Initialize(nullptr);
@@ -101,6 +103,9 @@ int main(int argc, char** argv)
LOG_INFO("server.authserver", "> Using Boost version: {}.{}.{}", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
});
for (std::string const& key : overriddenKeys)
LOG_INFO("server.authserver", "Configuration field {} was overridden with environment variable.", key);
OpenSSLCrypto::threadsSetup();
std::shared_ptr<void> opensslHandle(nullptr, [](void*) { OpenSSLCrypto::threadsCleanup(); });