本文整理汇总了C++中HttpServer::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpServer::Init方法的具体用法?C++ HttpServer::Init怎么用?C++ HttpServer::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpServer
的用法示例。
在下文中一共展示了HttpServer::Init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST_F(HttpServerTest, SimpleCase) {
HttpServer server;
ASSERT_TRUE(server.Init("0.0.0.0", 8712));
ASSERT_TRUE(server.Start());
}
示例2: main
int main(int argc, char* argv[])
{
enum { single, replicated, missing } mode;
int logTargets;
const char* user;
char buf[4096];
bool deleteDB;
bool firstRun;
firstRun = true;
mode = missing;
if (argc == 1)
{
fprintf(stderr, "You did not specify a config file!\n");
fprintf(stderr, "Starting in single mode with defaults...\n");
fprintf(stderr, "Using database.dir = '%s'\n", DATABASE_CONFIG_DIR);
mode = single;
}
else if (argc == 2)
{
if (!Config::Init(argv[1]))
STOP_FAIL("Cannot open config file", 1);
}
else
{
fprintf(stderr, "usage: %s <config-file>\n", argv[0]);
STOP_FAIL("invalid arguments", 1);
}
if (strcmp("single", Config::GetValue("mode", "")) == 0)
mode = single;
else if (strcmp("replicated", Config::GetValue("mode", "")) == 0)
mode = replicated;
else if (mode == missing)
{
fprintf(stderr, "specify mode = single or mode = replicated\n");
STOP_FAIL("invalid configuration file", 1);
}
logTargets = 0;
if (Config::GetListNum("log.targets") == 0)
logTargets = LOG_TARGET_STDOUT;
for (int i = 0; i < Config::GetListNum("log.targets"); i++)
{
if (strcmp(Config::GetListValue("log.targets", i, ""), "file") == 0)
{
logTargets |= LOG_TARGET_FILE;
Log_SetOutputFile(Config::GetValue("log.file", NULL),
Config::GetBoolValue("log.truncate", false));
}
if (strcmp(Config::GetListValue("log.targets", i, NULL), "stdout") == 0)
logTargets |= LOG_TARGET_STDOUT;
if (strcmp(Config::GetListValue("log.targets", i, NULL), "stderr") == 0)
logTargets |= LOG_TARGET_STDERR;
}
Log_SetTarget(logTargets);
Log_SetTrace(Config::GetBoolValue("log.trace", false));
Log_SetTimestamping(Config::GetBoolValue("log.timestamping", false));
Log_Message(VERSION_FMT_STRING " started");
run:
{
if (!IOProcessor::Init(Config::GetIntValue("io.maxfd", 1024)))
STOP_FAIL("Cannot initalize IOProcessor!", 1);
// 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;
//.........这里部分代码省略.........