From f2b1506bab59aa31f8488c5d19c0ee752fa0c559 Mon Sep 17 00:00:00 2001 From: Intel Date: Fri, 26 Jul 2013 02:20:36 +0300 Subject: [PATCH] Added config file, fixed library linking, include directories, etc --- CMakeLists.txt | 4 +- src/server/poolserver/CMakeLists.txt | 6 +- src/server/poolserver/Main.cpp | 19 ++- src/server/poolserver/poolserver.cfg.dist | 164 ++++++++++++++++++++++ src/server/shared/CMakeLists.txt | 1 + src/server/shared/Logging/Log.h | 2 +- 6 files changed, 181 insertions(+), 15 deletions(-) create mode 100644 src/server/poolserver/poolserver.cfg.dist diff --git a/CMakeLists.txt b/CMakeLists.txt index df140d3..d08a918 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,10 @@ set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) set(Boost_ALL_DYN_LINK ON) +SET(Boost_ADDITIONAL_VERSIONS "1.54" "1.54.0") + # Boost -find_package(Boost 1.53 COMPONENTS thread chrono program_options date_time REQUIRED) +find_package(Boost 1.54 COMPONENTS thread chrono program_options date_time REQUIRED) message(status "** Boost Include: ${Boost_INCLUDE_DIR}") message(status "** Boost Libraries: ${Boost_LIBRARY_DIRS}") message(status "** Boost Libraries: ${Boost_LIBRARIES}") diff --git a/src/server/poolserver/CMakeLists.txt b/src/server/poolserver/CMakeLists.txt index 90cb969..e437a16 100644 --- a/src/server/poolserver/CMakeLists.txt +++ b/src/server/poolserver/CMakeLists.txt @@ -29,15 +29,15 @@ add_executable(poolserver # Link libraries target_link_libraries(poolserver shared - ${MYSQL_LIBRARY} ${Boost_LIBRARIES} - /usr/local/lib/libboost_thread.so.1.53.0 - /usr/local/lib/libboost_program_options.so + ${MYSQL_LIBRARY} ) # Install if(UNIX) install(TARGETS poolserver DESTINATION bin) + install(FILES poolserver.cfg.dist DESTINATION bin) elseif(WIN32) install(TARGETS poolserver DESTINATION "${CMAKE_INSTALL_PREFIX}") + install(FILES poolserver.cfg.dist DESTINATION "${CMAKE_INSTALL_PREFIX}") endif() diff --git a/src/server/poolserver/Main.cpp b/src/server/poolserver/Main.cpp index d08edb7..e3cd8c3 100644 --- a/src/server/poolserver/Main.cpp +++ b/src/server/poolserver/Main.cpp @@ -1,21 +1,20 @@ -#include - #include "Server.h" #include "Config.h" #include "Log.h" #include #include +#include bool InitConfig(int argc, char *argv[]) { // Containers - boost::program_options::options_description descGeneric; - boost::program_options::options_description descServer; - boost::program_options::options_description descStratum; - boost::program_options::options_description descLogging; - boost::program_options::options_description descDatabase; + boost::program_options::options_description descGeneric("Generic Options"); + boost::program_options::options_description descServer("Server Configuration"); + boost::program_options::options_description descStratum("Stratum Configuration"); + boost::program_options::options_description descLogging("Logging Configuration"); + boost::program_options::options_description descDatabase("Database Configuration"); #ifdef WITH_MYSQL - boost::program_options::options_description descMySQL; + boost::program_options::options_description descMySQL("MySQL Configuration"); #endif boost::program_options::options_description cmdlineOptions; boost::program_options::options_description fileOptions; @@ -24,7 +23,7 @@ bool InitConfig(int argc, char *argv[]) descGeneric.add_options() ("version,v", "print version string") ("help,h", "produce help message") - ("config,c", boost::program_options::value()->default_value("settings.cfg"),"name of a file of a configuration.") + ("config,c", boost::program_options::value()->default_value("poolserver.cfg"),"name of a file of a configuration.") ; // Server @@ -78,7 +77,7 @@ bool InitConfig(int argc, char *argv[]) std::ifstream ifs(sConfig.Get("config").c_str()); if (!ifs.is_open()) { - sLog.Error(LOG_GENERAL, "Failed opening config file: %s", sConfig.Get("LogFilePath").c_str()); + sLog.Error(LOG_GENERAL, "Failed opening config file: %s", sConfig.Get("config").c_str()); return false; } diff --git a/src/server/poolserver/poolserver.cfg.dist b/src/server/poolserver/poolserver.cfg.dist new file mode 100644 index 0000000..613f56d --- /dev/null +++ b/src/server/poolserver/poolserver.cfg.dist @@ -0,0 +1,164 @@ +############################# +# Server Configuration File +############################# + +################################################################################################### +# SECTION INDEX +# +# SERVER CONFIGURATION +# STRATUM CONFIGURATION +# DATABASE CONFIGURATION +# MYSQL CONFIGURATION +# +################################################################################################### + +################################################################################################### +# EXAMPLE CONFIG +# +# Variable +# Description: Brief description what the variable is doing. +# Important: Annotation for important things about this variable. +# Example: "Example, i.e. if the value is a string" +# Default: 10 - (Enabled|Comment|Variable name in case of grouped config options) +# 0 - (Disabled|Comment|Variable name in case of grouped config options) +# +# Note to developers: +# - Copy this example to keep the formatting. +# - Line breaks should be at column 100. +################################################################################################### + +[Server Configuration] + +################################################################################################### +# SERVER CONFIGURATION +# +# MinDiffTime +# Description: Minimum diff time (ms) in main server loop. +# Important: Lowering this value increases cpu load but new packets are processed faster +# Default: 100 + +MinDiffTime=100 + +# +################################################################################################### + +[Stratum Configuration] + +################################################################################################### +# STRATUM CONFIGURATION +# +# StratumHost +# Description: Bind stratum to IP/Hostname +# Default: "0.0.0.0" - (Bind to all IPs on the system) + +StratumHost="0.0.0.0" + +# +# StratumPort +# Description: Stratum Port +# Default: 3333 + +StratumPort=3333 + +# +################################################################################################### + +[Logging Configuration] + +################################################################################################### +# LOGGING CONFIGURATION +# +# LogFilePath +# Description: Location to save logfile to +# Important: Do not add trailing slash +# Example: "/var/log" +# Default: "." - (Save log file next to executable) + +LogFilePath="." + +# +# LogConsoleLevel +# LogFileLevel +# Description: Logging output level +# Default: 0 - (Disabled) +# 1 - (Error) +# 2 - (Warning|LogFileLevel) +# 3 - (Info|LogConsoleLevel) +# 4 - (Debug|Set apropriate Log...DebugMask for debug output) + +LogConsoleLevel=4 +LogFileLevel=4 + +# +# LogConsoleDebugMask +# LogFileDebugMask +# Description: Debug output mask +# Example: 5 - (1+4|Ouput LOG_GENERAL and LOG_DATABASE) +# Default: 0 - (Disabled) +# 1 - (LOG_GENERAL) +# 2 - (LOG_SERVER) +# 4 - (LOG_DATABASE) + +LogConsoleDebugMask=0 +LogFileDebugMask=0 + +# +################################################################################################### + +[Database Configuration] + +################################################################################################### +# DATABASE CONFIGURATION +# +# DatabaseDriver +# Description: Database driver to use for data storage +# Important: Server must be compiled with selected driver support +# Example: "mysql" +# Default: "." - (Save log file next to executable) + +DatabaseDriver="mysql" + +# +################################################################################################### + +[MySQL Configuration] + +################################################################################################### +# MYSQL CONFIGURATION +# +# MySQLHost +# Description: IP/Hostname of MySQL Server +# Default: "127.0.0.1" - (Connect to localhost) + +MySQLHost="127.0.0.1" + +# +# MySQLPort +# Description: MySQL Server Port +# Default: 3306 - (Default MySQL Server Port) + +MySQLPort=3306 + +# +# MySQLUser +# Description: MySQL Server Username +# Default: "" - (No Username) + +MySQLUser="" + +# +# MySQLPass +# Description: MySQL Server Password +# Default: "" - (No Password) + +MySQLPass="" + +# +# MySQLDatabase +# Description: Name of MySQL Database +# Default: "poolserver" + +MySQLDatabase="poolserver" + +# +################################################################################################### diff --git a/src/server/shared/CMakeLists.txt b/src/server/shared/CMakeLists.txt index 0788a96..cf7017a 100644 --- a/src/server/shared/CMakeLists.txt +++ b/src/server/shared/CMakeLists.txt @@ -20,6 +20,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/Configuration ${CMAKE_CURRENT_SOURCE_DIR}/Database ${CMAKE_CURRENT_SOURCE_DIR}/Logging + ${Boost_INCLUDE_DIR} ${MYSQL_INCLUDE_DIR} ) diff --git a/src/server/shared/Logging/Log.h b/src/server/shared/Logging/Log.h index cd3e6b4..4fa6e87 100644 --- a/src/server/shared/Logging/Log.h +++ b/src/server/shared/Logging/Log.h @@ -25,7 +25,7 @@ enum LogLevel LOG_LEVEL_ERROR = 1, LOG_LEVEL_WARN = 2, LOG_LEVEL_INFO = 3, - LOG_LEVEL_DEBUG = 4 + LOG_LEVEL_DEBUG = 4 }; class Log