crawlserv++
[under development]
Application for crawling and analyzing textual content of websites.
|
The command-and-control server. More...
#include <Server.hpp>
Construction and Destruction | |
Server (const ServerSettings &serverSettings, const DatabaseSettings &databaseSettings, const NetworkSettings &networkSettings) | |
Constructor setting server, database, and network settings. More... | |
virtual | ~Server () |
Destructor interrupting and waiting for all threads. More... | |
Getters | |
const std::string & | getStatus () const |
Gets the status of the server. More... | |
std::int64_t | getUpTime () const |
Gets the up-time of the server in seconds. More... | |
std::size_t | getActiveThreads () const |
Gets the number of active module threads. More... | |
std::size_t | getActiveWorkers () const |
Gets the number of active worker threads. More... | |
Server Tick | |
bool | tick () |
Perform a server tick. More... | |
Copy and Move | |
Server (Server &)=delete | |
Deleted copy constructor. More... | |
Server & | operator= (Server &)=delete |
Deleted copy assignment operator. More... | |
Server (Server &&)=delete | |
Deleted move constructor. More... | |
Server & | operator= (Server &&)=delete |
Deleted move assignment operator. More... | |
The command-and-control server.
Uses the Main::WebServer and the rapidJSON
library to implement a HTTP server for receiving JSON-formatted commands and sending JSON-formatted replies from/to the crawlserv_frontend(s)
.
Also handles the threads for the different modules as well as worker threads for specific server tasks.
For more information about the rapidJSON
library, see its GitHub repository.
crawlservpp::Main::Server::Server | ( | const ServerSettings & | serverSettings, |
const DatabaseSettings & | databaseSettings, | ||
const NetworkSettings & | networkSettings | ||
) |
Constructor setting server, database, and network settings.
serverSettings | Constant reference to a structure containing the server settings. |
databaseSettings | Constant reference to a structure containing the database settings. |
networkSettings | Constant reference to a structure containing the network settings. |
Main::Exception | if the configuration could not be parsed, the configuration is invalid, or an unknown thread module is encountered. |
References crawlservpp::Main::cookieDir, crawlservpp::Struct::DatabaseSettings::debugDir, crawlservpp::Struct::DatabaseSettings::debugLogging, crawlservpp::Main::downloadDir, crawlservpp::Struct::ServerSettings::port, and crawlservpp::Struct::ServerSettings::sleepOnSqlErrorS.
|
virtual |
Destructor interrupting and waiting for all threads.
|
delete |
Deleted copy constructor.
|
delete |
Deleted move constructor.
std::size_t crawlservpp::Main::Server::getActiveThreads | ( | ) | const |
Gets the number of active module threads.
std::size_t crawlservpp::Main::Server::getActiveWorkers | ( | ) | const |
Gets the number of active worker threads.
const std::string & crawlservpp::Main::Server::getStatus | ( | ) | const |
Gets the status of the server.
Referenced by tick().
std::int64_t crawlservpp::Main::Server::getUpTime | ( | ) | const |
Gets the up-time of the server in seconds.
References crawlservpp::Helper::DateTime::now().
Referenced by tick().
bool crawlservpp::Main::Server::tick | ( | ) |
Perform a server tick.
Polls the web server, handles database exceptions, checks for finished threads to be cleared, checks the connection to the database, gets information about the status of the server, and performs server commands received from the frontend(s).
References crawlservpp::Data::_string, crawlservpp::Data::_uint64, crawlservpp::Main::Database::addConfiguration(), crawlservpp::Main::Database::addQuery(), crawlservpp::Main::Database::addUrlList(), crawlservpp::Main::Database::addWebsite(), crawlservpp::Struct::ServerSettings::allowedClients, crawlservpp::Main::cacheDir, crawlservpp::Main::Database::checkConnection(), crawlservpp::Main::Database::checkDataDir(), crawlservpp::Helper::Strings::checkDomainName(), crawlservpp::Helper::Strings::checkSQLName(), crawlservpp::Helper::FileSystem::clearDirectory(), crawlservpp::Main::Database::clearLogs(), crawlservpp::Main::WebServer::close(), crawlservpp::Data::GetColumnsMixed::columns_types, crawlservpp::Data::Compression::Gzip::compress(), crawlservpp::Data::Compression::Zlib::compress(), crawlservpp::Data::Compression::Zip::compress(), crawlservpp::Data::GetColumnsMixed::condition, crawlservpp::Struct::ThreadOptions::config, crawlservpp::Struct::ServerCommandResponse::confirm, crawlservpp::Main::Database::connect(), crawlservpp::Helper::FileSystem::contains(), crawlservpp::Helper::DateTime::convertCustomDateTimeToSQLTimeStamp(), crawlservpp::Main::cookieDir, crawlservpp::Helper::FileSystem::createDirectory(), crawlservpp::Helper::FileSystem::createDirectoryIfNotExists(), crawlservpp::Struct::ServerSettings::dataDeletable, crawlservpp::Main::dataTypeColumnNameSeparatorLong, crawlservpp::Main::dataTypeColumnNameSeparatorShort, crawlservpp::Data::Compression::Gzip::decompress(), crawlservpp::Data::Compression::Zlib::decompress(), crawlservpp::Main::Database::deleteConfiguration(), crawlservpp::Main::Database::deleteQuery(), crawlservpp::Main::Database::deleteUrlList(), crawlservpp::Main::Database::deleteUrls(), crawlservpp::Main::Database::deleteWebsite(), crawlservpp::Main::dictDir, crawlservpp::Main::Database::duplicateConfiguration(), crawlservpp::Main::Database::duplicateQuery(), crawlservpp::Main::Database::duplicateWebsite(), crawlservpp::Data::ImportExport::Text::exportList(), crawlservpp::Data::ImportExport::OpenDocument::exportSpreadsheet(), crawlservpp::Struct::ServerCommandResponse::fail, crawlservpp::Struct::ServerCommandResponse::failed(), crawlservpp::Helper::Memory::free(), crawlservpp::Helper::Json::free(), crawlservpp::Helper::Strings::generateRandom(), crawlservpp::Query::JsonPath::getAll(), crawlservpp::Query::JsonPointer::getAll(), crawlservpp::Query::XPath::getAll(), crawlservpp::Query::RegEx::getAll(), crawlservpp::Query::JsonPath::getBool(), crawlservpp::Query::JsonPointer::getBool(), crawlservpp::Query::XPath::getBool(), crawlservpp::Query::RegEx::getBool(), crawlservpp::Main::Database::getChangedUrlsByWebsiteUpdate(), crawlservpp::Main::Database::getConfiguration(), crawlservpp::Main::Database::getConnectionId(), crawlservpp::Main::Database::getCustomData(), crawlservpp::Main::Database::getDataDir(), crawlservpp::Main::Database::getDriverVersion(), crawlservpp::Query::JsonPath::getFirst(), crawlservpp::Query::JsonPointer::getFirst(), crawlservpp::Query::XPath::getFirst(), crawlservpp::Query::RegEx::getFirst(), crawlservpp::Main::WebServer::getIP(), crawlservpp::Main::Database::getLostUrlsByWebsiteUpdate(), crawlservpp::Main::Database::getMaxAllowedPacketSize(), crawlservpp::Main::Database::getNumberOfLogEntries(), crawlservpp::Helper::FileSystem::getPathSeparator(), crawlservpp::Main::Database::getQueryProperties(), getStatus(), crawlservpp::Query::JsonPath::getSubSets(), crawlservpp::Query::JsonPointer::getSubSets(), crawlservpp::Query::XPath::getSubSets(), crawlservpp::Main::Database::getTargetTableName(), crawlservpp::Main::Database::getThreads(), getUpTime(), crawlservpp::Main::Database::getUrlListNamespace(), crawlservpp::Main::Database::getUrls(), crawlservpp::Main::Database::getUrlsWithIds(), crawlservpp::Main::Database::getWebsiteDataDirectory(), crawlservpp::Main::Database::getWebsiteDomain(), crawlservpp::Main::Database::getWebsiteFromUrlList(), crawlservpp::Main::Database::getWebsiteNamespace(), crawlservpp::Main::httpsString, crawlservpp::Main::httpString, crawlservpp::Struct::ServerCommandResponse::id, crawlservpp::Struct::ThreadStatus::id, crawlservpp::Data::ImportExport::Text::importList(), crawlservpp::Module::Analyzer::Algo::initAlgo(), crawlservpp::Main::WebServer::initHTTP(), crawlservpp::Main::Database::initializeSql(), crawlservpp::Main::Database::isConfiguration(), crawlservpp::Main::Database::isTargetTable(), crawlservpp::Helper::FileSystem::isValidDirectory(), crawlservpp::Helper::FileSystem::isValidFile(), crawlservpp::Helper::Utf8::length(), crawlservpp::Helper::FileSystem::listFilesInPath(), crawlservpp::Helper::CommaLocale::locale(), crawlservpp::Module::Database::log(), crawlservpp::Main::Database::log(), crawlservpp::Struct::ServerSettings::logsDeletable, MAIN_SERVER_CMD, MAIN_SERVER_WORKER_BEGIN, MAIN_SERVER_WORKER_END, crawlservpp::Main::mdlDir, crawlservpp::Main::Database::mergeUrls(), crawlservpp::Main::minNameSpaceLength, crawlservpp::Main::minNameSpaceLengthString, crawlservpp::Main::Database::moveQuery(), crawlservpp::Helper::DateTime::now(), crawlservpp::Struct::ThreadDatabaseEntry::options, crawlservpp::Main::optionsHttpCode, crawlservpp::Parsing::XML::parse(), crawlservpp::Helper::Json::parseCons(), crawlservpp::Helper::Json::parseRapid(), crawlservpp::Main::WebServer::poll(), crawlservpp::Module::Database::prepare(), crawlservpp::Main::Database::prepare(), crawlservpp::Main::randFileNameLength, crawlservpp::Data::File::read(), crawlservpp::Main::Database::readColumnAsStrings(), crawlservpp::Main::Database::readTableAsStrings(), crawlservpp::Main::replyHttpCode, crawlservpp::Main::replyHttpContentType, crawlservpp::Main::Database::resetAnalyzingStatus(), crawlservpp::Main::Database::resetExtractingStatus(), crawlservpp::Main::Database::resetParsingStatus(), crawlservpp::Struct::QueryProperties::resultBool, crawlservpp::Helper::DateTime::secondsToString(), crawlservpp::Main::WebServer::send(), crawlservpp::Main::WebServer::sendFile(), crawlservpp::Main::WebServer::setAcceptCallback(), crawlservpp::Main::WebServer::setLogCallback(), crawlservpp::Parsing::XML::setOptions(), crawlservpp::Main::WebServer::setRequestCallback(), crawlservpp::Main::Database::setSleepOnError(), crawlservpp::Struct::ServerSettings::sleepOnSqlErrorS, crawlservpp::Struct::ThreadDatabaseEntry::status, crawlservpp::Main::statusHttpCode, crawlservpp::Main::statusHttpContentType, crawlservpp::Helper::Json::stringify(), crawlservpp::Data::GetColumnsMixed::table, crawlservpp::Struct::QueryProperties::text, crawlservpp::Struct::ServerCommandResponse::text, crawlservpp::Timer::SimpleHR::tickStr(), crawlservpp::Timer::Simple::tickStr(), crawlservpp::Struct::ServerCommandResponse::toBeConfirmed(), crawlservpp::Helper::Strings::trim(), crawlservpp::Struct::QueryProperties::type, crawlservpp::Main::Database::update(), crawlservpp::Main::Database::updateConfiguration(), crawlservpp::Main::Database::updateQuery(), crawlservpp::Main::Database::updateUrlList(), crawlservpp::Main::Database::updateWebsite(), crawlservpp::Data::GetColumnsMixed::values, crawlservpp::Main::Exception::view(), crawlservpp::Main::webServerPollTimeOutMs, crawlservpp::Data::File::write(), and crawlservpp::Main::xmlWarningsDefault.