Search code examples
c++drogon-framework

c++ framework drogon how to use different config.json for different environments?


When using the c++ framework drogon, the configuration I want to use for local development, e.g. mysql configuration is: localhost:3306. Then when pushing the code to the test or main branch, I want to use the configuration xxx.com:3306.

How can I configure multiple config.json without having to change the same config.json when pushing code?

Simply put, i want to have two sets of config files, config.json and config.test.json, and then main.cc automatically loads different configs based on the environment, but I don't know how to achieve this.


Solution

  • OK, I knew the answer, just use environment variables to define the config file name.