Files
spark/src/server/sparkd/cmds/Web.cpp
T
John Colvin ca4e477f56 fix: CLI11 integration
* Run 'sparkd tests' outside of the CLI::App framework
  (delegate to 'catch', which has a solid cli).  This
  fixes a bug which prevented callers from specifying
  test tags (in the form of '[<tag>]'), as the CLI::App's
  parse method removes square brackets from cli options.

* Bind cli options to instance members of their subcommand's
  CLI::App derived class.  This seems to fix a bug which caused
  the [static instance] binding source to be destructed twice.

 * Add help text for several subcommands
2021-01-16 00:01:15 -06:00

67 lines
1.9 KiB
C++

#include "Web.h"
#include "lib/api/public/ServiceContext.h"
#include "lib/config/config.h"
#include "lib/config/protos/Ports.pb.h"
#include "lib/config/protos/quickbus_cfg.pb.h"
#include "lib/quickbus/quickbus.h"
#include "lib/md/MDClient.h"
#include "lib/md/SyntheticSecurityService.h"
#include "lib/md/relay/QueryServer.h"
#include "lib/metrics/metrics.h"
#include "lib/metrics/system_metrics.h"
#include "lib/tracing/PerfLog.h"
#include "server/sparkd/http/WebServer.h"
#include "server/sparkd/md/run_md.h"
#include "server/sparkd/user/AdminServiceServer.h"
#include "server/sparkd/user/AuthServiceServer.h"
#include <string>
#include <vector>
namespace bts::cmds {
struct Web::Args {
bool md;
};
Web::Web()
: CLI::App(
"Run only the services required for the web admin. This cannot be "
"run concurrently with 'sparkd run.'",
"web"),
_args(new Web::Args()) {
add_flag("--md", _args->md, "Start market data");
callback([&] {
config::QuickbusNodeCfg qb_cfg;
auto &ports = config::get<config::Ports>();
qb_cfg.set_my_port(ports.qbus_port());
qbus::Quickbus quickbus(qb_cfg);
api::ServiceContext sc(&quickbus);
metrics::MetricsContainer stats;
metrics::publish_system_metrics(stats);
trace::PerfLog perf_log;
http::SparkWebServer webserver(sc, stats, perf_log, ports.config_port());
user::AuthServiceServer login_server(sc);
if (_args->md) {
md::run_market_datapublishers(nullptr, nullptr);
}
api::synthetic::SyntheticSecurityService synthetic_service(sc);
md::MDClient mdclient(&utils::Dispatcher::current(), &synthetic_service);
md::QueryServerPtr md_query_server(
md::run_query_server(sc, mdclient, stats));
admin::AdminServiceServer admin_service(sc);
utils::Dispatcher::current().run();
});
}
Web::~Web() {}
} // namespace bts::cmds