Skip to content
Snippets Groups Projects

Small Fixes to GUI server

Merged Markus Frank requested to merge satellite into master
1 file
+ 37
4
Compare changes
  • Side-by-side
  • Inline
@@ -74,6 +74,8 @@ namespace Online {
/// Access histogram list by regular expression
json task_histogram(const std::string& dns, const std::string& task, const std::string& selection);
/// Access histogram list by regular expression
json task_regex_histogram(const std::string& dns, const std::string& task, const std::string& selection);
/// Access histogram list by regular expression
json task_histograms_regex(const std::string& dns, const std::string& task, const std::string& selection);
/// List histogram pages for implementation of the presenter
@@ -100,6 +102,7 @@ namespace Online {
// C++ include files
#include <iostream>
#include <stdexcept>
#include <fstream>
#include <memory>
// Framework includes
@@ -239,6 +242,32 @@ GauchoRPC::json GauchoRPC::task_histogram(const std::string& dns, const std::str
return answer;
}
/// Access histogram list by regular expression
GauchoRPC::json GauchoRPC::task_regex_histogram(const std::string& dns, const std::string& task, const std::string& selection) {
_check_dns_task(this, dns, task);
std::vector<std::string> tasks;
HistTaskJson::taskList(dns, tasks);
auto flags = std::regex_constants::icase;
std::regex regex(task, flags);
for( const auto& t : tasks ) {
std::smatch sm;
bool stat = std::regex_match(t, sm, regex);
if ( stat ) {
HistTaskJson obj(t, dns);
auto answer = obj.histos(selection);
if ( answer.size() > 0 ) {
++m_counters.numSuccess;
return answer.at(0);
}
++m_counters.numError;
return answer;
}
}
++m_counters.numError;
return {};
}
/// List histogram pages for implementation of the presenter
GauchoRPC::json GauchoRPC::list_histogram_pages() {
struct Scanner {
@@ -270,7 +299,7 @@ GauchoRPC::json GauchoRPC::list_histogram_pages() {
//std::cout << obj << std::endl;
return obj;
}
#include <fstream>
/// Load single histogram page identified by the relative path
GauchoRPC::json GauchoRPC::load_histogram_page(const std::string& path) {
std::filesystem::path loc(pages_location.string()+path.substr(path.find("/",1)));
@@ -290,14 +319,17 @@ static void help_server() {}
/// Main entry point to start the application
extern "C" int run_gaucho_rpc(int argc, char** argv) {
int debug = 0;
int port = 8000;
int debug = 0;
int threads = 0;
int port = 8000;
std::string host = "0.0.0.0";
for(int i = 0; i < argc && argv[i]; ++i) {
if ( 0 == ::strncmp("-port",argv[i],4) )
port = ::atol(argv[++i]);
else if ( 0 == ::strncmp("-host",argv[i],4) )
host = argv[++i];
else if ( 0 == ::strncmp("-threads",argv[i],3) )
threads = ::atol(argv[++i]);
else if ( 0 == ::strncmp("-debug",argv[i],4) )
debug = 1;
else if ( 0 == ::strncmp("-help",argv[i],2) )
@@ -316,6 +348,7 @@ extern "C" int run_gaucho_rpc(int argc, char** argv) {
(*json_handler)->define("task_histogram_directory", jsonrpc::Call(&callable).make(&GauchoRPC::task_histogram_directory));
(*json_handler)->define("task_histograms_regex", jsonrpc::Call(&callable).make(&GauchoRPC::task_histograms_regex));
(*json_handler)->define("task_histogram", jsonrpc::Call(&callable).make(&GauchoRPC::task_histogram));
(*json_handler)->define("task_regex_histogram", jsonrpc::Call(&callable).make(&GauchoRPC::task_regex_histogram));
callable.pages_location = "/home/frankm/Presenter/web/Pages";
(*json_handler)->define("list_histogram_pages", jsonrpc::Call(&callable).make(&GauchoRPC::list_histogram_pages));
@@ -329,7 +362,7 @@ extern "C" int run_gaucho_rpc(int argc, char** argv) {
rpc::HttpServer server(std::move(handler), host, port, rpc::HttpServer::SERVER);
server.setDebug(debug != 0);
::dis_start_serving(RTL::processName().c_str());
server.start(false,0);
server.start(false, threads);
return 0;
}
Loading