111 lines
4.1 KiB
C++
111 lines
4.1 KiB
C++
#include "Run.h"
|
|
#include "ICmd.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/logging/logging.h"
|
|
#include "lib/os/os.h"
|
|
#include "lib/quickbus/quickbus.h"
|
|
#include "lib/utils/Dispatcher.h"
|
|
|
|
#include "lib/config/protos/toggles.pb.h"
|
|
#include "lib/md/MDClient.h"
|
|
#include "lib/md/SyntheticSecurityService.h"
|
|
#include "lib/md/relay/QueryServer.h"
|
|
#include "lib/md/MBOProcessor.h"
|
|
#include "lib/md/MBOServiceServer.h"
|
|
#include "lib/metrics/metrics.h"
|
|
#include "lib/metrics/system_metrics.h"
|
|
#include "lib/orderman/order_factory/DynamicOrderRegistry.h"
|
|
#include "lib/orderman/server/OrderServiceServer.h"
|
|
#include "lib/persistence/PersistenceServiceServer.h"
|
|
#include "lib/plugin/SparkServices.h"
|
|
#include "lib/plugin/plugin.h"
|
|
#include "lib/tracing/PerfLog.h"
|
|
#include "lib/utils/thread_manager.h"
|
|
#include "server/sparkd/http/WebServer.h"
|
|
#include "server/sparkd/md/MarketDataAuxiliaryServiceServer.h"
|
|
#include "server/sparkd/md/run_md.h"
|
|
#include "server/sparkd/position/PositionServiceServer.h"
|
|
#include "server/sparkd/support/ErrorReportService.h"
|
|
#include "server/sparkd/support/ShellLatencyServer.h"
|
|
#include "server/sparkd/user/AdminServiceServer.h"
|
|
#include "server/sparkd/user/AuthServiceServer.h"
|
|
#include "server/sparkd/algo/AlgoServiceServer.h"
|
|
#include "server/sparkd/algo/AlgoDefinitionServiceServer.h"
|
|
#include <thread>
|
|
|
|
namespace bts {
|
|
namespace cmd {
|
|
|
|
int Run::execute(std::vector<std::string> const &) {
|
|
using namespace bts;
|
|
LOG(Gen, Warn,
|
|
"------------------------------------ Sparkd launched "
|
|
"--------------------------------");
|
|
|
|
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);
|
|
|
|
trace::PerfLog perf_log;
|
|
metrics::MetricsContainer stats;
|
|
metrics::publish_system_metrics(stats);
|
|
http::SparkWebServer webserver(sc, stats, perf_log, ports.config_port());
|
|
|
|
persistence::PersistenceServiceServer settings_saver(sc, "settings");
|
|
user::AuthServiceServer login_server(sc);
|
|
|
|
md::MBOProcessor mbo(&utils::Dispatcher::get_named("MBO"));
|
|
auto* mbowriter = config::get<config::toggles::PlacementInQueue>().enabled() ? &mbo.writer() : nullptr;
|
|
md::run_market_datapublishers(mbowriter);
|
|
|
|
api::synthetic::SyntheticSecurityService synthetic_service(sc);
|
|
md::MDClient mdclient(&utils::Dispatcher::background(), &synthetic_service, &mbo.reader());
|
|
|
|
md::QueryServerPtr md_query_server(
|
|
md::run_query_server(sc, mdclient, stats));
|
|
|
|
md::MBOServiceServer mboserver(sc, utils::Dispatcher::background(), mdclient);
|
|
|
|
// initialize order plugins
|
|
orderman::DynamicOrderRegistry dyn_order_registry;
|
|
SparkServices plugin_services(dyn_order_registry);
|
|
plugin::init_plugins(plugin_services);
|
|
// finished initializing order plugins
|
|
|
|
orderman::OrderServiceServer order_service_server(
|
|
sc, mdclient, dyn_order_registry, stats, perf_log);
|
|
support::ErrorReportServer error_report_service(sc);
|
|
admin::AdminServiceServer admin_service(sc);
|
|
md::auxiliary::MarketDataAuxiliaryServiceServer md_aux_server(sc);
|
|
//orderman::AlgoServiceServer algo_server(sc);
|
|
bts::api::orderman::algo::AlgoDefinitionServiceServer algo_definition_server(sc);
|
|
position::PositionServiceServer position_service(sc);
|
|
metrics::ShellLatencyServer shell_latency_service(
|
|
sc, stats, utils::Dispatcher::background());
|
|
|
|
auto bg_health =
|
|
std::make_shared<metrics::IntCounterMetric>("spark_background_thread");
|
|
utils::DispatcherTimer timer(utils::Dispatcher::background(), 5000,
|
|
[=]() { bg_health->increment(); });
|
|
timer.start();
|
|
|
|
utils::DispatcherTimer timer2(utils::Dispatcher::background(), 1000,
|
|
[&]() { perf_log.store_log_entries(); });
|
|
timer2.start();
|
|
stats.publish(bg_health);
|
|
|
|
std::this_thread::sleep_until(
|
|
std::chrono::time_point<std::chrono::system_clock>::max());
|
|
return 0;
|
|
}
|
|
|
|
std::string Run::help() { return "\t run default sparkd services"; }
|
|
} // namespace cmd
|
|
} // namespace bts
|