当前位置: 首页>>代码示例>>C++>>正文


C++ HttpServer::Shutdown方法代码示例

本文整理汇总了C++中HttpServer::Shutdown方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpServer::Shutdown方法的具体用法?C++ HttpServer::Shutdown怎么用?C++ HttpServer::Shutdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpServer的用法示例。


在下文中一共展示了HttpServer::Shutdown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........

		// after io is initialized, drop root rights
		user = Config::GetValue("daemon.user", NULL);
		if (!ChangeUser(user))
			STOP_FAIL(rprintf("Cannot setuid to %s", user), 1);

		DatabaseConfig dbConfig;
		dbConfig.dir = Config::GetValue("database.dir", DATABASE_CONFIG_DIR);
		dbConfig.pageSize = Config::GetIntValue("database.pageSize", DATABASE_CONFIG_PAGE_SIZE);
		dbConfig.cacheSize = Config::GetIntValue("database.cacheSize", DATABASE_CONFIG_CACHE_SIZE);
		dbConfig.logBufferSize = Config::GetIntValue("database.logBufferSize", DATABASE_CONFIG_LOG_BUFFER_SIZE);
		dbConfig.checkpointTimeout = Config::GetIntValue("database.checkpointTimeout", DATABASE_CONFIG_CHECKPOINT_TIMEOUT);
		dbConfig.verbose = Config::GetBoolValue("database.verbose", DATABASE_CONFIG_VERBOSE);
		dbConfig.directDB = Config::GetBoolValue("database.directDB", DATABASE_CONFIG_DIRECT_DB);
		dbConfig.txnNoSync = Config::GetBoolValue("database.txnNoSync", DATABASE_CONFIG_TXN_NOSYNC);
		dbConfig.txnWriteNoSync = Config::GetBoolValue("database.txnWriteNoSync", DATABASE_CONFIG_TXN_WRITE_NOSYNC);

		if (Config::GetBoolValue("database.warmCache", true) && firstRun)
			WarmCache((char*)dbConfig.dir, dbConfig.cacheSize);

		if (firstRun)
			Log_Message("Opening database...");
		if (!database.Init(dbConfig))
			STOP_FAIL("Cannot initialize database!", 1);
		if (firstRun)
			Log_Message("Database opened");

		dbWriter.Init(1);
		dbReader.Init(Config::GetIntValue("database.numReaders", 20));
		
		if (!RCONF->Init())
			STOP_FAIL("Cannot initialize paxos!", 1);

		KeyspaceDB* kdb;
		if (mode == replicated)
		{
			RLOG->Init(Config::GetBoolValue("paxos.useSoftClock", true));
			kdb = new ReplicatedKeyspaceDB;
		}
		else
		{
			kdb = new SingleKeyspaceDB;
		}

		kdb->Init();
		
		HttpServer protoHttp;
		HttpKeyspaceHandler httpKeyspaceHandler(kdb);
		
		int httpPort = Config::GetIntValue("http.port", 8080);
		if (httpPort)
		{
			protoHttp.Init(httpPort);
			protoHttp.RegisterHandler(&httpKeyspaceHandler);
		}

		KeyspaceServer protoKeyspace;
		protoKeyspace.Init(kdb, Config::GetIntValue("keyspace.port", 7080));
		
		EventLoop::Init();
		EventLoop::Run();
		EventLoop::Shutdown();
			
		if (mode == replicated)
			deleteDB = ((ReplicatedKeyspaceDB*)kdb)->DeleteDB();
		else
			deleteDB = false;
		
		protoKeyspace.Shutdown();
		protoHttp.Shutdown();
		
		kdb->Shutdown();
		delete kdb;
		dbReader.Shutdown();
		dbWriter.Shutdown();
		RLOG->Shutdown();
		database.Shutdown();
		IOProcessor::Shutdown();
		
		if (mode == replicated && deleteDB)
		{
//			snprintf(buf, SIZE(buf), "%s/__*", dbConfig.dir);
//			DeleteWC(buf);
			snprintf(buf, SIZE(buf), "%s/log*", dbConfig.dir);
			DeleteWC(buf);
			snprintf(buf, SIZE(buf), "%s/keyspace", dbConfig.dir);
			DeleteWC(buf);
#ifdef _WIN32
			MSleep(3000); // otherwise Windows won't let use reuse the same ports
#endif
			firstRun = false;
			goto run;
		}
	}

	Log_Message("Keyspace shutting down.");	
	Config::Shutdown();
	Log_Shutdown();

}
开发者ID:agazso,项目名称:keyspace,代码行数:101,代码来源:Main.cpp


注:本文中的HttpServer::Shutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。