bool Config::loadConfigFile() { std::string dirPath; #ifndef _DEBUG dirPath = getExecutablePath(); #else dirPath = getCurrentDirectory(); #endif // if we have an env variable set for this, use that... const char* smPathEnv = getenv("SITEMON_PATH"); if (smPathEnv && strlen(smPathEnv) > 0) { dirPath.assign(smPathEnv); } if (dirPath.substr(dirPath.size() - 1, 1) != "/") { dirPath += "/"; } std::string finalPath = dirPath; // try XML config file first... if (loadXMLConfigFile(finalPath + "sm_config.xml")) { return true; } return false; }
void CCMApp::init() { CGenericApp::setAppName("cm"); CGenericApp::initI10N(); CGenericApp::initLogSystem(); CLog::instance()->log(CLog::msgLvlVerbose,_("Initializing cluster manager server...\n")); if (!CGenericApp::printPIDToFile()) CLog::instance()->log(CLog::msgLvlWarn,_("PID file was not written!\n")); if (!CGenericApp::loadXMLConfigFile("../config/defaults/config.xml", true)) { CLog::instance()->log(CLog::msgLvlCritical,_("Config file loading failure!\n")); shutdown(); } // we have defaults, so it's ok if config.xml is missing loadXMLConfigFile("../config/config.xml"); if (!checkRequiredConfigOptions()) { CLog::instance()->log(CLog::msgLvlCritical,_("One or more required options not found!\n")); shutdown(); } if ( SDLNet_Init() < 0 ) { CLog::instance()->log(CLog::msgFlagNetwork, CLog::msgLvlCritical,_("Couldn't initialize net: %s\n"), SDLNet_GetError()); shutdown(); } m_id = atoi(m_config->getFirstValue("/config/id").c_str());; if( m_id == 0 ) m_id = 1; m_worlds = m_config->getAllValuesForKey("/config/wsConnections/wsAddress"); setPulseHandlers(); CCMDB::init(); if (!initCMConnectionsManager()) shutdown(); /*if (!initInternalServer()) shutdown();*/ if (!initRootServerConnection()) shutdown(); }
void CRootApp::init() { CGenericApp::setAppName("rs"); CGenericApp::initI10N(); CGenericApp::initLogSystem(); CLog::instance()->log(CLog::msgLvlVerbose,_("Initializing root server...\n")); if (!CGenericApp::printPIDToFile()) CLog::instance()->log(CLog::msgLvlWarn,_("PID file was not written!\n")); if (!loadXMLConfigFile("../config/defaults/config.xml", true)) { CLog::instance()->log(CLog::msgLvlCritical,_("Default configuration file loading failure!\n")); shutdown(); } // we have defaults, so it's ok if config.xml is missing loadXMLConfigFile("../config/config.xml"); if (!checkRequiredConfigOptions()) { CLog::instance()->log(CLog::msgLvlCritical,_("One or more required options not found!\n")); shutdown(); } if ( SDLNet_Init() < 0 ) { CLog::instance()->log(CLog::msgFlagNetwork, CLog::msgLvlCritical, _("Couldn't initialize net: %s\n"), SDLNet_GetError()); shutdown(); } CRootDB::init(); CLog::instance()->log(CLog::msgFlagMysql, CLog::msgLvlVerbose,_("Initializing MySQL database connection...\n")); if (!CMySQLConnection::instance()->init(m_config->getFirstValue("/config/database/db").c_str(), m_config->getFirstValue("/config/database/user").c_str(), m_config->getFirstValue("/config/database/password").c_str(), m_config->getFirstValue("/config/database/host").c_str(), atoi(m_config->getFirstValue("/config/database/port").c_str()))) { CLog::instance()->log(CLog::msgFlagMysql, CLog::msgLvlCritical,_("Could not initialize database connection!\n")); shutdown(); } if (m_config->getFirstValue("/config/database/tableNamesPrefix") != "") CMySQLConnection::instance()->setTableNamesPrefix( m_config->getFirstValue("/config/database/tableNamesPrefix") ); CLog::instance()->log(CLog::msgFlagMysql, CLog::msgLvlVerbose,_("Done.\n")); m_clusters = m_config->getAllValuesForKey("/config/internalConnections/cmAddress"); if (!initInternalServer()) shutdown(); if (!initExternalServer()) shutdown(); CLog::instance()->log(CLog::msgLvlVerbose,_("Done root server initialization.\n")); }