void init_env() { char logfile[256]; char fname[32]; adhome = getenv("ADHOME"); sprintf(fname, "log/harvest-%s.txt", TimeUtil::get_yymmdd() ); StrUtil::path_merge(logfile, adhome, fname); // log file append mode: ofstream::app ACE_OSTREAM_TYPE *output = new ofstream(logfile, ofstream::app); ACE_LOG_MSG->msg_ostream(output, 1); ACE_LOG_MSG->set_flags(ACE_Log_Msg::OSTREAM); ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR); ACE_DEBUG ((LM_STARTUP, "[%T] -- START UP --\n")); if (adhome) ACE_DEBUG ((LM_INFO, "ADHOME = %s\n", adhome)); else ACE_DEBUG ((LM_INFO, "ADHOME is NOT set !\n")); config.open_home(adhome, "anydict.cfg"); PORT = config.GetIntVal("HARVEST_PORT", PORT); ACE_DEBUG ((LM_INFO, "SERVER PORT = %d\n", PORT)); if (strcasecmp(config.GetStrVal("DEBUG"), "YES")==0) { ACE_LOG_MSG->priority_mask( LM_DEBUG | LM_INFO | LM_NOTICE | LM_ALERT | LM_WARNING | LM_ERROR, ACE_Log_Msg::PROCESS); } else { ACE_LOG_MSG->priority_mask( LM_INFO | LM_NOTICE | LM_ALERT | LM_WARNING | LM_ERROR, ACE_Log_Msg::PROCESS); } }
Manager::Manager(string configfile) { m_iPid = 0; m_pSocket = NULL; m_pClientSock = NULL; m_semRequest = NULL; m_mtxRequest = NULL; m_pUserProcess = NULL; m_iRegisterTestTimeelaspe = 0; m_iRegisterCount = 0; m_iSearchTestTimeelaspe = 0; m_iSearchCount = 0; m_iDownloadTestTimeelaspe = 0; m_iDownloadCount = 0; Config* config = Config::Instance(); if( config->ParseConfig(configfile.c_str(), "SYSTEM") != 0) { cout<<"parse config file:["<<configfile<<"] failed, exit"<<endl; exit(-1); } m_strServerIp = config->GetStrVal("SYSTEM", "serverip", "0.0.0.0"); m_iServerPort = config->GetIntVal("SYSTEM", "serverport", 5550); m_strPeerIp = config->GetStrVal("SYSTEM", "peerip", "0.0.0.0"); m_iPeerPort = config->GetIntVal("SYSTEM", "peerport", 5555); m_iPeerThreadPoolNum = config->GetIntVal("SYSTEM", "threadnum", 5); m_strPeerFileBufferDir = config->GetStrVal("SYSTEM", "filebufferdir", "./file/"); m_strPeerFileDownloadDir = config->GetStrVal("SYSTEM", "downloaddir", "./download/"); m_iTestMode = config->GetIntVal("SYSTEM", "testmode", 0); }