diff options
-rw-r--r-- | docs/manaserv.xml | 12 | ||||
-rw-r--r-- | src/account-server/main-account.cpp | 65 | ||||
-rw-r--r-- | src/game-server/main-game.cpp | 59 |
3 files changed, 85 insertions, 51 deletions
diff --git a/docs/manaserv.xml b/docs/manaserv.xml index 0be0d94..f487432 100644 --- a/docs/manaserv.xml +++ b/docs/manaserv.xml @@ -55,6 +55,18 @@ <!-- end of database configuration *************************************** --> <!-- + Log levels configuration. + Available values are: + 0. Fatal Errors only. + 1. All Errors. + 2. Plus warnings. + 3. Plus standard information. + 4. Plus debugging information. + --> + <option name="log_gameServerLogLevel" value="2"/> + <option name="log_accountServerLogLevel" value="2"/> + + <!-- New player starting location. The map should be defined in data/maps.xml. --> <option name="char_startMap" value="1"/> diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp index 39c111a..e43f1a6 100644 --- a/src/account-server/main-account.cpp +++ b/src/account-server/main-account.cpp @@ -75,6 +75,36 @@ static void closeGracefully(int) running = false; } +static void initConfig() +{ + /* + * If the path values aren't defined, we set the default + * depending on the platform. + */ + // The config path +#if defined CONFIG_FILE + std::string configPath = CONFIG_FILE; +#else + +#if (defined __USE_UNIX98 || defined __FreeBSD__) + std::string configPath = getenv("HOME"); + configPath += "/."; + configPath += DEFAULT_CONFIG_FILE; +#else // Win32, ... + std::string configPath = DEFAULT_CONFIG_FILE; +#endif + +#endif // defined CONFIG_FILE + Configuration::initialize(configPath); + LOG_INFO("Using config file: " << configPath); + // check inter-server password + if (Configuration::getValue("net_password", "") == "") + { + LOG_WARN("SECURITY WARNING: No 'net_password' set in " << configPath << + " - set one ASAP or this server WILL get h4x0rd!!"); + } +} + /** * Initializes the server. */ @@ -97,21 +127,6 @@ static void initialize() * If the path values aren't defined, we set the default * depending on the platform. */ - // The config path -#if defined CONFIG_FILE - std::string configPath = CONFIG_FILE; -#else - -#if (defined __USE_UNIX98 || defined __FreeBSD__) - std::string configPath = getenv("HOME"); - configPath += "/."; - configPath += DEFAULT_CONFIG_FILE; -#else // Win32, ... - std::string configPath = DEFAULT_CONFIG_FILE; -#endif - -#endif // defined CONFIG_FILE - // The log path #if defined LOG_FILE std::string logPath = LOG_FILE; @@ -137,19 +152,10 @@ static void initialize() // write the messages to both the screen and the log file. Logger::setTeeMode(true); - Configuration::initialize(configPath); - LOG_INFO("Using config file: " << configPath); LOG_INFO("Using log file: " << logPath); ResourceManager::initialize(); - // check inter-server password - if (Configuration::getValue("net_password", "") == "") - { - LOG_WARN("SECURITY WARNING: No net_password set in " << configPath << - " - set one ASAP or this server WILL get h4x0rd!!"); - } - // Open database try { storage = new Storage; @@ -261,9 +267,8 @@ static void printHelp() struct CommandLineOptions { CommandLineOptions(): - verbosity(Logger::Info), - port(Configuration::getValue("net_accountServerPort", - DEFAULT_SERVER_PORT)) + verbosity(Logger::Warn), + port(DEFAULT_SERVER_PORT) {} Logger::Level verbosity; @@ -318,9 +323,15 @@ int main(int argc, char *argv[]) #ifdef PACKAGE_VERSION LOG_INFO("The Mana Account+Chat Server v" << PACKAGE_VERSION); #endif + initConfig(); // Parse command line options CommandLineOptions options; + options.verbosity = static_cast<Logger::Level>( + Configuration::getValue("log_accountServerLogLevel", + options.verbosity) ); + options.port = Configuration::getValue("net_accountServerPort", + options.port); parseOptions(argc, argv, options); Logger::setVerbosity(options.verbosity); diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp index 19ffa93..fd85053 100644 --- a/src/game-server/main-game.cpp +++ b/src/game-server/main-game.cpp @@ -97,20 +97,10 @@ void closeGracefully(int) } /** - * Initializes the server. + * Initialize the configuration */ -void initialize() +void initConfig() { - // Reset to default segmentation fault handling for debugging purposes - signal(SIGSEGV, SIG_DFL); - - // Used to close via process signals -#if (defined __USE_UNIX98 || defined __FreeBSD__) - signal(SIGQUIT, closeGracefully); -#endif - signal(SIGINT, closeGracefully); - signal(SIGTERM, closeGracefully); - /* * If the path values aren't defined, we set the default * depending on the platform. @@ -127,9 +117,32 @@ void initialize() #else // Win32, ... std::string configPath = DEFAULT_CONFIG_FILE; #endif - #endif // defined CONFIG_FILE + Configuration::initialize(configPath); + LOG_INFO("Using config file: " << configPath); + +} + +/** + * Initializes the server. + */ +void initialize() +{ + // Reset to default segmentation fault handling for debugging purposes + signal(SIGSEGV, SIG_DFL); + + // Used to close via process signals +#if (defined __USE_UNIX98 || defined __FreeBSD__) + signal(SIGQUIT, closeGracefully); +#endif + signal(SIGINT, closeGracefully); + signal(SIGTERM, closeGracefully); + + /* + * If the path values aren't defined, we set the default + * depending on the platform. + */ // The log path #if defined LOG_FILE std::string logPath = LOG_FILE; @@ -154,9 +167,6 @@ void initialize() // Write the messages to both the screen and the log file. Logger::setTeeMode(true); - - Configuration::initialize(configPath); - LOG_INFO("Using config file: " << configPath); LOG_INFO("Using log file: " << logPath); // --- Initialize the managers @@ -255,8 +265,8 @@ void printHelp() struct CommandLineOptions { CommandLineOptions(): - verbosity(Logger::Info), - port(0) + verbosity(Logger::Warn), + port(DEFAULT_SERVER_PORT + 3) {} Logger::Level verbosity; @@ -313,20 +323,21 @@ int main(int argc, char *argv[]) LOG_INFO("The Mana Game Server v" << PACKAGE_VERSION); #endif + initConfig(); + // Parse command line options CommandLineOptions options; + options.verbosity = static_cast<Logger::Level>( + Configuration::getValue("log_gameServerLogLevel", + options.verbosity) ); + options.port = Configuration::getValue("net_gameServerPort", options.port); parseOptions(argc, argv, options); + Logger::setVerbosity(options.verbosity); // General initialization initialize(); - if (options.port < 1) - { - options.port = Configuration::getValue("net_gameServerPort", - DEFAULT_SERVER_PORT + 3); - } - // Make an initial attempt to connect to the account server // Try again after longer and longer intervals when connection fails. bool isConnected = false; |