Files
spark/src/server/sparkd/cmds/Web.cpp
T

57 lines
1.8 KiB
C++

#include "Web.h"
#include "lib/config/config.h"
#include "lib/config/protos/quickbus_cfg.pb.h"
#include "lib/config/protos/Ports.pb.h"
#include "lib/quickbus/quickbus.h"
#include "lib/api/public/ServiceContext.h"
#include "server/sparkd/metrics/metrics.h"
#include "server/sparkd/metrics/system_metrics.h"
#include "server/sparkd/http/WebServer.h"
#include "lib/md/relay/QueryServer.h"
#include "lib/md/SyntheticSecurityService.h"
#include "server/sparkd/user/AdminServiceServer.h"
#include "server/sparkd/user/UserServiceServer.h"
#include "server/sparkd/md/run_md.h"
#include <vector>
#include <string>
namespace bts {
namespace cmd {
int Web::execute(const std::vector<std::string>& args) {
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);
http::SparkWebServer webserver(sc, stats, ports.config_port());
user::UserServiceServer login_server(sc);
if (std::find(args.begin(), args.end(), "-md") != args.end()) {
md::run_market_datapublishers();
}
std::shared_ptr<api::ISyntheticSecurityService> synthetic_service =
std::make_shared<api::synthetic::SyntheticSecurityService>(sc);
md::QueryServerPtr md_query_server(
md::run_query_server(sc, synthetic_service, stats));
admin::AdminServiceServer admin_service(sc);
std::this_thread::sleep_until(
std::chrono::time_point<std::chrono::system_clock>::max());
return 0;
}
std::string Web::help() { return "\t run only the services required for the web admin. This cannot be run concurrently with 'sparkd run'\n\tAdd -md to start market data too."; }
}}//namespace