Пример #1
0
int main()
{
	Log.Init(3);
	Log.Color(TBLUE);
	printf("Schumix Verzio: %s\n", revision);
	printf("A program leallitasahoz hasznald a <Ctrl+C> parancsot vagy <kikapcs>\n\n");
	Log.Color(TNORMAL);
	printf("Keszulesi ido: %s %s\n", BUILD_DATE, BUILD_TIME);
	printf("Keszitette Megax, Twl, Valroft es Scymex http://megaxx.info\n");
	printf("==============================================================================\n");
	printf("\n");
	Log.Notice("Schumix", "Rendszer indul...\n");

#if PLATFORM == PLATFORM_WINDOWS
	// WSA Setup
	WSADATA info;
	int error;

	if((err = WSAStartup(MAKEWORD(2, 2), &info)) != 0)
	{
		Log.Error("WSA", "Hiba tortent a WSA inicializalasanal. Hibakod: %i", error);
		return -1;
	}
#endif

	Log.Notice("Config", "Config fajl betoltese...");

	string config = string(Elnevezes) + ".conf";

	// Config fájl
	if(!Config.MainConfig.SetSource(format("./%s", config.c_str()).c_str()))
	{
		Log.Error("Config", ">> %s", config.c_str());
		new DefaultConfig(config);

		if(Config.MainConfig.SetSource(format("./%s", config.c_str()).c_str()))
			Log.Success("Config", ">> Config adatbazis sikeresen betoltve.");
		else
		{
			Log.Error("Config", ">> Ujabb sikertelen betoltes. Ellenorizze le kezileg.");
			return 0;
		}
	}
	else
		Log.Success("Config", ">> %s", config.c_str());

	printf("\n");

	Log.Init(cast_uint8(Config.MainConfig.GetIntDefault("Log", "Loglevel", 3)));
	new Vezerlo();

#if PLATFORM == PLATFORM_WINDOWS
	WSACleanup();
#endif

	Log.Notice("Schumix", "Program leallt.");
	return 0;
}
Пример #2
0
//---------------------------------------------------------------------------------------------------------------------------
//Constructor
//---------------------------------------------------------------------------------------------------------------------------
CIocpServer::CIocpServer()
:m_Threads(0),m_CLThreads(0),m_bAdo(false),m_UnlimitPort(UNLIMIT_PORT_START)
{
	//初始化内存池对象
	m_sockobj = new cFixedMemoryPool(sizeof(SOCKET_OBJ),(int)(AVERAGE_CONNECTIONS*2),1);
	m_bufobj = new cFixedMemoryPool(sizeof(BUFFER_OBJ),(int)(AVERAGE_CONNECTIONS*3));
	m_buffer  =  new cFixedMemoryPool(DEFAULT_BUFFER_SIZE,(int)(AVERAGE_CONNECTIONS*3));

	InitializeCriticalSectionAndSpinCount(&secAlive,SPIN_COUNT_ALIVE);
	InitializeCriticalSectionAndSpinCount(&secClose,SPIN_COUNT_CLOSE);

	m_Inited = false;
	CompletionPort = INVALID_HANDLE_VALUE;
	CLCompletionPort = INVALID_HANDLE_VALUE;
	m_accept_count = 0;

#ifdef LOG_ENABLE	//根据可执行文件名,自动创建一个日志文件.
	char log_name[512];
	char *pname;
	GetModuleFileName(NULL,log_name,sizeof(log_name));
	pname = log_name+strlen(log_name) -1;
	*pname = 't';pname--;
	*pname = 'x';pname--;
	*pname = 't';
	if(Log_Server.Init(log_name))
		printf("创建Log:\"%s\"   ",log_name);
#endif

}
Пример #3
0
	BOOL CLogMgr::Init()
	{
		CLog* logDBG = new CLog();
		logDBG->Init("log/", "DBG_MSG", 1);
		m_mapLog[DBG_MSG] = logDBG;
		CLog* logINFO = new CLog();
		logDBG->Init("log/", "INFO_MSG", 1);
		m_mapLog[INFO_MSG] = logDBG;
		CLog* logWARN = new CLog();
		logDBG->Init("log/", "WARN_MSG", 1);
		m_mapLog[WARN_MSG] = logDBG;
		CLog* logERR = new CLog();
		logDBG->Init("log", "ERR_MSG", 1);
		m_mapLog[ERR_MSG] = logDBG;
		return TRUE;
	}
Пример #4
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char *pszCmdLine, int nShowCmd)
{
	CLog log;
	log.Init(Debug, "AtmosphereTest", 0);
	CGameApp app(hInstance, hPrevInstance, pszCmdLine, nShowCmd);
	if(app.InitInstance())
		app.Run();
	return app.ExitInstance();
}
Пример #5
0
int main(int args, char ** argv)
{

    CSockAddr loAddr;
    loAddr.Set("127.0.0.1", 4001);
    CLog* lpoLog = Instance<CLog>();
    CProcessManager* lpoProcessor = Instance<CProcessManager>();
    CCycle* lpoCycle = GetCycle();
    CIoConnector loConnector(lpoCycle);

    lpoCycle->GetConfiguration()->SetMaxListener(10);
    lpoCycle->GetConfiguration()->SetMaxSession(1024);
    lpoCycle->GetConfiguration()->SetReadBufferSize(1024);
    lpoCycle->GetConfiguration()->SetWriteBufferSize(1024);
    lpoCycle->GetConfiguration()->SetReadIdle(5);
    lpoCycle->GetConfiguration()->SetWriteIdle(5);
    lpoCycle->GetConfiguration()->SetWriteTimeout(1024);
    lpoCycle->GetConfiguration()->SetAutoSuspendWrite(false);
    lpoCycle->GetConfiguration()->SetAutoResumeRead(false);
    lpoCycle->GetConfiguration()->SetMaxHint(1024);
    lpoCycle->GetConfiguration()->SetProcessors(1);
    lpoCycle->GetConfiguration()->SetThreadStackSize(1024);
    lpoCycle->GetConfiguration()->SetMaxDelay(600);

    lpoLog->Init(5, "log.log", 1024);
    lpoCycle->Init();
    loConnector.SetHandler(new CHttpHandler());

    lpoProcessor->BackupEnvirons(argv);
    lpoProcessor->SetTitle((char*)"Master");
    lpoProcessor->Bind(lpoCycle);
    loConnector.Connect("Test", loAddr, 3);
//    loConnector.Connect("Test", loAddr1, 3);
    TestTimer tt;
    tt.Init();
    lpoCycle->GetTimer()->Add(&tt, 2 * 1000);
    lpoProcessor->Loop();
    delete lpoCycle;

    return 0;
}
Пример #6
0
int main(int argc, char *argv[])
{
	CLog log;
	log.Init(Debug, "GLCloud2");
	LogInfo("Starting app (%s)", g_strBuildStamp.c_str());
	CProfiler profile("main", 3, Info);

	CKernel *pKernel = CKernel::Create();
	pKernel->AddTask(CTimerTask::Create(10));
	pKernel->AddTask(CInputTask::Create(20));
	pKernel->AddTask(CInterpolatorTask::Create(30));
	pKernel->AddTask(CTriggerTask::Create(40));
	pKernel->AddTask(CCameraTask::Create(50));
	pKernel->AddTask(CVideoTask::Create(10000));

	pKernel->AddTask(CAppTask::Create(100));
	pKernel->Execute();
	pKernel->Destroy();

	LogInfo("Closing app");
	return 0;
}
Пример #7
0
Файл: coam.cpp Проект: isub/coam
int InitCoAManager ()
{
	int iRetVal = 0;

	do {
		std::vector<std::string> vectConfParam;
		std::string strConfParam;

		iRetVal = g_coConf.GetParamValue ("log_file_mask", strConfParam);
		if (iRetVal) {
			UTL_LOG_F(g_coLog, "Log file mask not defined");
			break;
		}
		/* инициализация логгера */
		iRetVal = g_coLog.Init (strConfParam.c_str());
		if (iRetVal) {
			UTL_LOG_F(g_coLog, "can not initialize log writer: code: '%d'", iRetVal);
			break;
		}
		/* изменение пользователя и группы владельца демона */
		ChangeOSUser ();

		std::string strDBPoolSize;
		int iDBPoolSize;
		int iFnRes;

		const char *pcszConfParam = "db_pool_size";
		iFnRes = g_coConf.GetParamValue( pcszConfParam, strDBPoolSize );
		if( iFnRes || 0 == strDBPoolSize.length() ) {
			UTL_LOG_F( g_coLog, "dbpool: configuration parameter '%s' not defined", pcszConfParam );
		} else {
			iDBPoolSize = atoi( strDBPoolSize.c_str() );
		}

		std::string strDBUser, strDBPswd, strDBDescr;

		pcszConfParam = "db_user";
		iFnRes = g_coConf.GetParamValue( pcszConfParam, strDBUser );
		if( iFnRes || 0 == strDBUser.length() ) {
			UTL_LOG_F( g_coLog, "dbpool: configuration parameter '%s' not defined", pcszConfParam );
		}

		/* запрашиваем пароль пользователя БД из конфигурации */
		pcszConfParam = "db_pswd";
		iFnRes = g_coConf.GetParamValue( pcszConfParam, strDBPswd );
		if( iFnRes || 0 == strDBPswd.length() ) {
			UTL_LOG_F( g_coLog, "dbpool: configuration parameter '%s' not defined", pcszConfParam );
		}

		/* запрашиваем дескриптор БД из конфигурации */
		pcszConfParam = "db_descr";
		iFnRes = g_coConf.GetParamValue( pcszConfParam, strDBDescr );
		if( iFnRes || 0 == strDBDescr.length() ) {
			UTL_LOG_F( g_coLog, "dbpool: configuration parameter '%s' not defined", pcszConfParam );
		}

		/* инициализация пула подклчений к БД */
		iRetVal = db_pool_init(&g_coLog, strDBUser, strDBPswd, strDBDescr, iDBPoolSize );
		if (iRetVal) {
			UTL_LOG_F(g_coLog, "can not initialize DB pool");
		}
		/* создание списка NASов */
		iRetVal = CreateNASList (&g_mapNASList);
		if (iRetVal) {
			break;
		}
		/* инициализация пула потоков */
		iRetVal = InitThreadPool ();
		if (iRetVal) {
			break;
		}
	} while (0);

	return iRetVal;
}