diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2011-11-01 13:44:38 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2011-11-01 17:13:46 +0100 |
commit | 5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed (patch) | |
tree | 19d2d94b8c90ccb9a24529102431e6a68c0b7a4b /src/account-server | |
parent | fba5a19e5885e3f4ddca2c249a96fbbe24c846b8 (diff) | |
download | manaserv-5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed.tar.gz manaserv-5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed.tar.bz2 manaserv-5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed.tar.xz manaserv-5922e27d2bc4d2b5ab906afbe2bc029ac90cb2ed.zip |
Have one place where the Configuration is initialized
Also, removed the fallback to the standard config file path when a
config file path is specified on the command line. Surely that's not
what you would want to happen.
Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src/account-server')
-rw-r--r-- | src/account-server/main-account.cpp | 56 |
1 files changed, 12 insertions, 44 deletions
diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp index 0adf1285..19ffb23f 100644 --- a/src/account-server/main-account.cpp +++ b/src/account-server/main-account.cpp @@ -56,7 +56,6 @@ using utils::Logger; // Default options that automake should be able to override. #define DEFAULT_LOG_FILE "manaserv-account.log" #define DEFAULT_STATS_FILE "manaserv.stats" -#define DEFAULT_CONFIG_FILE "manaserv.xml" #define DEFAULT_ATTRIBUTEDB_FILE "attributes.xml" static bool running = true; /**< Determines if server keeps running */ @@ -82,47 +81,6 @@ static void closeGracefully(int) running = false; } -static void initializeConfiguration(std::string configPath = std::string()) -{ - if (configPath.empty()) - configPath = DEFAULT_CONFIG_FILE; - - bool configFound = true; - if (!Configuration::initialize(configPath)) - { - configFound = false; - - // If the config file isn't the default and fail to load, - // we try the default one with a warning. - if (configPath.compare(DEFAULT_CONFIG_FILE)) - { - LOG_WARN("Invalid config path: " << configPath - << ". Trying default value: " << DEFAULT_CONFIG_FILE "."); - configPath = DEFAULT_CONFIG_FILE; - configFound = true; - - if (!Configuration::initialize(configPath)) - configFound = false; - } - - if (!configFound) - { - LOG_FATAL("Refusing to run without configuration!" << std::endl - << "Invalid config path: " << configPath << "."); - exit(EXIT_CONFIG_NOT_FOUND); - } - } - - LOG_INFO("Using config file: " << configPath); - - // Check inter-server password. - if (Configuration::getValue("net_password", std::string()).empty()) - { - LOG_FATAL("SECURITY WARNING: 'net_password' not set!"); - exit(EXIT_BAD_CONFIG_PARAMETER); - } -} - /** * Initializes the server. */ @@ -263,7 +221,6 @@ static void printHelp() struct CommandLineOptions { CommandLineOptions(): - configPath(DEFAULT_CONFIG_FILE), verbosity(Logger::Warn), verbosityChanged(false), port(DEFAULT_SERVER_PORT), @@ -336,7 +293,18 @@ int main(int argc, char *argv[]) CommandLineOptions options; parseOptions(argc, argv, options); - initializeConfiguration(options.configPath); + if (!Configuration::initialize(options.configPath)) + { + LOG_FATAL("Refusing to run without configuration!"); + exit(EXIT_CONFIG_NOT_FOUND); + } + + // Check inter-server password. + if (Configuration::getValue("net_password", std::string()).empty()) + { + LOG_FATAL("SECURITY WARNING: 'net_password' not set!"); + exit(EXIT_BAD_CONFIG_PARAMETER); + } // General initialization initialize(); |