|
|
@ -9,41 +9,41 @@ bool InitConfig(int argc, char *argv[]) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Containers
|
|
|
|
// Containers
|
|
|
|
boost::program_options::options_description descGeneric("Generic Options"); |
|
|
|
boost::program_options::options_description descGeneric("Generic Options"); |
|
|
|
boost::program_options::options_description descServer("Server Configuration"); |
|
|
|
boost::program_options::options_description descServer("Server Configuration"); |
|
|
|
boost::program_options::options_description descStratum("Stratum Configuration"); |
|
|
|
boost::program_options::options_description descStratum("Stratum Configuration"); |
|
|
|
boost::program_options::options_description descLogging("Logging Configuration"); |
|
|
|
boost::program_options::options_description descLogging("Logging Configuration"); |
|
|
|
boost::program_options::options_description descDatabase("Database Configuration"); |
|
|
|
boost::program_options::options_description descDatabase("Database Configuration"); |
|
|
|
#ifdef WITH_MYSQL |
|
|
|
#ifdef WITH_MYSQL |
|
|
|
boost::program_options::options_description descMySQL("MySQL Configuration"); |
|
|
|
boost::program_options::options_description descMySQL("MySQL Configuration"); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
boost::program_options::options_description cmdlineOptions; |
|
|
|
boost::program_options::options_description cmdlineOptions; |
|
|
|
boost::program_options::options_description fileOptions; |
|
|
|
boost::program_options::options_description fileOptions; |
|
|
|
|
|
|
|
|
|
|
|
// Generic
|
|
|
|
// Generic
|
|
|
|
descGeneric.add_options() |
|
|
|
descGeneric.add_options() |
|
|
|
("version,v", "print version string") |
|
|
|
("version,v", "print version string") |
|
|
|
("help,h", "produce help message") |
|
|
|
("help,h", "produce help message") |
|
|
|
("config,c", boost::program_options::value<std::string>()->default_value("poolserver.cfg"),"name of a file of a configuration.") |
|
|
|
("config,c", boost::program_options::value<std::string>()->default_value("poolserver.cfg"),"name of a file of a configuration.") |
|
|
|
; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
// Server
|
|
|
|
// Server
|
|
|
|
descServer.add_options() |
|
|
|
descServer.add_options() |
|
|
|
("MinDiffTime", boost::program_options::value<uint32_t>()->default_value(100), "Minimum server diff time") |
|
|
|
("MinDiffTime", boost::program_options::value<uint32_t>()->default_value(100), "Minimum server diff time") |
|
|
|
; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
// Stratum
|
|
|
|
// Stratum
|
|
|
|
descStratum.add_options() |
|
|
|
descStratum.add_options() |
|
|
|
("StratumHost,sh", boost::program_options::value<std::string>()->default_value("0.0.0.0"), "Stratum server host") |
|
|
|
("StratumHost,sh", boost::program_options::value<std::string>()->default_value("0.0.0.0"), "Stratum server host") |
|
|
|
("StratumPort,sp", boost::program_options::value<uint16_t>()->default_value(3333), "Stratum server port") |
|
|
|
("StratumPort,sp", boost::program_options::value<uint16_t>()->default_value(3333), "Stratum server port") |
|
|
|
; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
// Logging
|
|
|
|
// Logging
|
|
|
|
descLogging.add_options() |
|
|
|
descLogging.add_options() |
|
|
|
("LogConsoleLevel", boost::program_options::value<uint32_t>()->default_value(LOG_LEVEL_INFO), "Console log level (0-None, 1-Error, 2-Warn, 3-Info, 4-Debug)") |
|
|
|
("LogConsoleLevel", boost::program_options::value<uint32_t>()->default_value(LOG_LEVEL_INFO), "Console log level (0-None, 1-Error, 2-Warn, 3-Info, 4-Debug)") |
|
|
|
("LogConsoleDebugMask", boost::program_options::value<uint32_t>()->default_value(0), "Console log debug mask") |
|
|
|
("LogConsoleDebugMask", boost::program_options::value<uint32_t>()->default_value(0), "Console log debug mask") |
|
|
|
("LogFilePath", boost::program_options::value<std::string>()->default_value("."), "File log path") |
|
|
|
("LogFilePath", boost::program_options::value<std::string>()->default_value("."), "File log path") |
|
|
|
("LogFileLevel", boost::program_options::value<uint32_t>()->default_value(LOG_LEVEL_WARN), "File log level (0-None, 1-Error, 2-Warn, 3-Info, 4-Debug)") |
|
|
|
("LogFileLevel", boost::program_options::value<uint32_t>()->default_value(LOG_LEVEL_WARN), "File log level (0-None, 1-Error, 2-Warn, 3-Info, 4-Debug)") |
|
|
|
("LogFileDebugMask", boost::program_options::value<uint32_t>()->default_value(0), "File log debug mask") |
|
|
|
("LogFileDebugMask", boost::program_options::value<uint32_t>()->default_value(0), "File log debug mask") |
|
|
|
; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
// Database
|
|
|
|
// Database
|
|
|
@ -62,39 +62,39 @@ bool InitConfig(int argc, char *argv[]) |
|
|
|
; |
|
|
|
; |
|
|
|
descDatabase.add(descMySQL); |
|
|
|
descDatabase.add(descMySQL); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
cmdlineOptions.add(descGeneric).add(descServer).add(descStratum).add(descLogging).add(descDatabase); |
|
|
|
cmdlineOptions.add(descGeneric).add(descServer).add(descStratum).add(descLogging).add(descDatabase); |
|
|
|
fileOptions.add(descServer).add(descStratum).add(descLogging).add(descDatabase); |
|
|
|
fileOptions.add(descServer).add(descStratum).add(descLogging).add(descDatabase); |
|
|
|
|
|
|
|
|
|
|
|
store(boost::program_options::command_line_parser(argc, argv).options(cmdlineOptions).run(), sConfig.vm); |
|
|
|
store(boost::program_options::command_line_parser(argc, argv).options(cmdlineOptions).run(), sConfig.vm); |
|
|
|
notify(sConfig.vm); |
|
|
|
notify(sConfig.vm); |
|
|
|
|
|
|
|
|
|
|
|
if (sConfig.vm.count("help")) { |
|
|
|
if (sConfig.vm.count("help")) { |
|
|
|
std::cout << cmdlineOptions << std::endl; |
|
|
|
std::cout << cmdlineOptions << std::endl; |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::ifstream ifs(sConfig.Get<std::string>("config").c_str()); |
|
|
|
std::ifstream ifs(sConfig.Get<std::string>("config").c_str()); |
|
|
|
|
|
|
|
|
|
|
|
if (!ifs.is_open()) { |
|
|
|
if (!ifs.is_open()) { |
|
|
|
sLog.Error(LOG_GENERAL, "Failed opening config file: %s", sConfig.Get<std::string>("config").c_str()); |
|
|
|
sLog.Error(LOG_GENERAL, "Failed opening config file: %s", sConfig.Get<std::string>("config").c_str()); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
store(parse_config_file(ifs, fileOptions), sConfig.vm); |
|
|
|
store(parse_config_file(ifs, fileOptions), sConfig.vm); |
|
|
|
notify(sConfig.vm); |
|
|
|
notify(sConfig.vm); |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) |
|
|
|
int main(int argc, char *argv[]) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!InitConfig(argc, argv)) |
|
|
|
if (!InitConfig(argc, argv)) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
sLog.OpenLogFile(sConfig.Get<std::string>("LogFilePath")); |
|
|
|
sLog.OpenLogFile(sConfig.Get<std::string>("LogFilePath")); |
|
|
|
sLog.Info(LOG_GENERAL, "LogFile Started: %s", sLog.logFileLoc.c_str()); |
|
|
|
sLog.Info(LOG_GENERAL, "LogFile Started: %s", sLog.logFileLoc.c_str()); |
|
|
|
|
|
|
|
|
|
|
|
Server* server = new Server(); |
|
|
|
Server* server = new Server(); |
|
|
|
int exitcode = server->Run(); |
|
|
|
int exitcode = server->Run(); |
|
|
|
delete server; |
|
|
|
delete server; |
|
|
|