diff --git a/CMakeLists.txt b/CMakeLists.txt index 5367af20..f8e46e5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,19 +34,11 @@ add_subdirectory( LatencyTest ) install(DIRECTORY ${CMAKE_SOURCE_DIR}/MiscATS/ DESTINATION MiscATS - FILES_MATCHING PATTERN "*.db" PATTERN "*.sh" PATTERN "*.ini" PATTERN "*.cfg") - -install(CODE " - file(GLOB_RECURSE SCRIPT_FILES - \"\${CMAKE_INSTALL_PREFIX}/MiscATS/*.sh\") - foreach(script \${SCRIPT_FILES}) - execute_process(COMMAND chmod +x \${script}) - endforeach() -") - -install(FILES FIXGateway/scripts/fixgateway.sh - DataService/scripts/dataservice.sh - MatchingEngine/scripts/matchingengine.sh + FILES_MATCHING PATTERN "*.db" PATTERN "*.py" PATTERN "*.ini" PATTERN "*.cfg" PATTERN "*.json") + +install(FILES FIXGateway/scripts/fix_gateway_manager.py + DataService/scripts/data_service_manager.py + MatchingEngine/scripts/matching_engine_manager.py DESTINATION scripts PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE diff --git a/DataService/scripts/data_service_manager.py b/DataService/scripts/data_service_manager.py new file mode 100644 index 00000000..3ea05653 --- /dev/null +++ b/DataService/scripts/data_service_manager.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python3 + +import os +import sys +import time +import subprocess +from pathlib import Path +import psutil + +PROGNAME = "DataService" + + +def get_config_file(): + if len(sys.argv) < 3: + print(f"Usage: {sys.argv[0]} [start|stop|check] ") + sys.exit(1) + return sys.argv[2] + + +def get_paths(config_file): + basedir = os.environ.get("BASEDIR_ATS", ".") + dats_home = os.environ.get("DATS_HOME") + if not dats_home: + print("DATS_HOME is not set.") + sys.exit(1) + + config_path = Path(basedir) / "config" / config_file + log_path = Path(basedir) / "logs" / f"{PROGNAME}.{config_file}.console.log" + binary_path = Path(dats_home) / "bin" / PROGNAME + return binary_path, config_path, log_path, basedir + + +def source_dats_env(): + dats_home = os.environ.get("DATS_HOME") + env_script = Path(dats_home) / "dats_env.sh" + if env_script.exists(): + subprocess.call(f"source {env_script}", shell=True, executable="/bin/bash") + + +def check_process(config_path): + for proc in psutil.process_iter(['pid', 'cmdline']): + try: + cmdline = proc.info['cmdline'] + if cmdline and PROGNAME in cmdline[0] and str(config_path) in ' '.join(cmdline): + print(f"{PROGNAME} [{config_path.name}] is running - {proc.pid}") + return proc.pid + except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): + continue + print(f"{PROGNAME} [{config_path.name}] is not running") + return None + + +def start_process(binary_path, config_path, log_path): + print(f"Starting: {PROGNAME} -c {config_path}") + for key in sorted(os.environ): + print(f"{key}={os.environ[key]}") + if check_process(config_path) is None: + with open(log_path, "a") as f: + subprocess.Popen([str(binary_path), "-c", str(config_path)], + stdout=f, stderr=subprocess.STDOUT) + time.sleep(1) + check_process(config_path) + + +def stop_process(config_path): + cmd_str = f"{PROGNAME} -c {config_path}" + print(f"Stopping: {cmd_str}") + pid = check_process(config_path) + if pid: + os.system(f"pkill -SIGTERM -f \"{cmd_str}\"") + time.sleep(1) + + for _ in range(10): + if check_process(config_path) is None: + break + time.sleep(1) + else: + os.system(f"pkill -KILL -U {os.getuid()} -f \"{cmd_str}\"") + + +def main(): + if len(sys.argv) < 3: + print(f"Usage: {sys.argv[0]} [start|stop|check] ") + sys.exit(1) + + command = sys.argv[1].lower() + config_file = get_config_file() + + binary_path, config_path, log_path, basedir = get_paths(config_file) + source_dats_env() + + if command == "start": + start_process(binary_path, config_path, log_path) + elif command == "stop": + stop_process(config_path) + elif command == "check": + check_process(config_path) + else: + print("Unknown command") + sys.exit(1) + + with open(log_path, "a") as f: + f.write(f"{time.strftime('%Y%m%d.%H%M%S')} run-done : pid,{os.getpid()}\n") + + +if __name__ == "__main__": + main() diff --git a/DataService/src/MarketDataService.cpp b/DataService/src/MarketDataService.cpp index 6e199628..6a7f3818 100644 --- a/DataService/src/MarketDataService.cpp +++ b/DataService/src/MarketDataService.cpp @@ -209,6 +209,8 @@ int MarketDataService::service (void) std::this_thread::sleep_for(std::chrono::duration(1000)); } }; + + return 0; } bool MarketDataService::populateMarketDataSnapshotFullRefresh( const Instrument& instrument, diff --git a/DataService/src/RefDataService.cpp b/DataService/src/RefDataService.cpp index e85fc3be..02fecf10 100644 --- a/DataService/src/RefDataService.cpp +++ b/DataService/src/RefDataService.cpp @@ -94,7 +94,8 @@ void RefDataService::populateUserGroupInstrumentMap() " m.market_name=im_map.market_name and " \ " im_map.market_name=ugm_map.market_name"); - LOG4CXX_INFO(logger, "Populating security list"); + LOG4CXX_INFO(logger, "Populating security list : "); + LOG4CXX_INFO(logger, "Query : " + sqliteQuery.getQuery()); m_sqliteConnection->execute(sqliteQuery); diff --git a/DataService/src/SQLiteConnection.hpp b/DataService/src/SQLiteConnection.hpp index 187d8667..32a1ef1e 100644 --- a/DataService/src/SQLiteConnection.hpp +++ b/DataService/src/SQLiteConnection.hpp @@ -42,8 +42,6 @@ class SQLiteQuery public: SQLiteQuery( const std::string& query ) : m_stmt(0), m_query( query ) { - - std::cout << query << std::endl; } ~SQLiteQuery() @@ -95,6 +93,11 @@ class SQLiteQuery { return m_rows[row][column]; } + + std::string getQuery() + { + return m_query; + } private: sqlite3_stmt* m_stmt; diff --git a/FIXGateway/scripts/fix_gateway_manager.py b/FIXGateway/scripts/fix_gateway_manager.py new file mode 100644 index 00000000..a137a7a2 --- /dev/null +++ b/FIXGateway/scripts/fix_gateway_manager.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python3 + +import os +import sys +import time +import subprocess +from pathlib import Path +import psutil + +PROGNAME = "FIXGateway" + + +def usage(): + print(f"Usage: {sys.argv[0]} [start|stop|check] ") + sys.exit(1) + + +def get_paths(config_file): + basedir = os.environ.get("BASEDIR_ATS", ".") + dats_home = os.environ.get("DATS_HOME") + if not dats_home: + print("DATS_HOME is not set.") + sys.exit(1) + + config_path = Path(basedir) / "config" / config_file + log_path = Path(basedir) / "logs" / f"{PROGNAME}.{config_file}.console.log" + binary_path = Path(dats_home) / "bin" / PROGNAME + return binary_path, config_path, log_path + + +def check_process(config_path): + for proc in psutil.process_iter(['pid', 'cmdline']): + try: + cmdline = proc.info['cmdline'] + if cmdline and PROGNAME in cmdline[0] and str(config_path) in ' '.join(cmdline): + print(f"{PROGNAME} [{config_path.name}] is running - {proc.pid}") + return proc.pid + except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): + continue + print(f"{PROGNAME} [{config_path.name}] is not running") + return None + + +def start_process(binary_path, config_path, log_path): + process_str = f"{PROGNAME} -c {config_path}" + print(f"Starting: {process_str}") + for key in sorted(os.environ): + print(f"{key}={os.environ[key]}") + if check_process(config_path) is None: + with open(log_path, "a") as f: + subprocess.Popen([str(binary_path), "-c", str(config_path)], + stdout=f, stderr=subprocess.STDOUT) + time.sleep(1) + check_process(config_path) + + +def stop_process(config_path): + process_str = f"{PROGNAME} -c {config_path}" + print(f"Stopping: {process_str}") + pid = check_process(config_path) + if pid: + os.system(f"pkill -SIGTERM -f \"{process_str}\"") + time.sleep(1) + + # Try up to 10 seconds to let it exit + for _ in range(10): + if check_process(config_path) is None: + break + time.sleep(1) + else: + os.system(f"pkill -KILL -U {os.getuid()} -f \"{process_str}\"") + + +def main(): + if len(sys.argv) < 3: + usage() + + command = sys.argv[1].lower() + config_file = sys.argv[2] + + binary_path, config_path, log_path = get_paths(config_file) + + if command == "start": + start_process(binary_path, config_path, log_path) + elif command == "stop": + stop_process(config_path) + elif command == "check": + check_process(config_path) + else: + usage() + + # Final run log + with open(log_path, "a") as f: + f.write(f"{time.strftime('%Y%m%d.%H%M%S')} run-done : pid,{os.getpid()}\n") + + +if __name__ == "__main__": + main() diff --git a/MatchingEngine/scripts/matching_engine_manager.py b/MatchingEngine/scripts/matching_engine_manager.py new file mode 100644 index 00000000..e8e22370 --- /dev/null +++ b/MatchingEngine/scripts/matching_engine_manager.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python3 + +import os +import sys +import time +import subprocess +from pathlib import Path +import psutil + +PROGNAME = "MatchingEngine" + +def get_config_file(): + if len(sys.argv) < 3: + print(f"Usage: {sys.argv[0]} [start|stop|check] ") + sys.exit(1) + return sys.argv[2] + + +def get_paths(config_file): + basedir = os.environ.get("BASEDIR_ATS", ".") + dats_home = os.environ.get("DATS_HOME") + if not dats_home: + print("DATS_HOME is not set.") + sys.exit(1) + + config_path = Path(basedir) / "config" / config_file + log_path = Path(basedir) / "logs" / f"{PROGNAME}.{config_file}.console.log" + binary_path = Path(dats_home) / "bin" / PROGNAME + return binary_path, config_path, log_path, basedir + + +def source_dats_env(): + dats_home = os.environ.get("DATS_HOME") + env_script = Path(dats_home) / "dats_env.sh" + if env_script.exists(): + subprocess.call(f"source {env_script}", shell=True, executable="/bin/bash") + + +def check_process(config_path): + for proc in psutil.process_iter(['pid', 'cmdline']): + try: + cmdline = proc.info['cmdline'] + if cmdline and PROGNAME in cmdline[0] and str(config_path) in ' '.join(cmdline): + print(f"{PROGNAME} [{config_path.name}] is running - {proc.pid}") + return proc.pid + except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): + continue + print(f"{PROGNAME} [{config_path.name}] is not running") + return None + + +def start_process(binary_path, config_path, log_path): + print(f"Starting: {PROGNAME} -c {config_path}") + for key in sorted(os.environ): + print(f"{key}={os.environ[key]}") + if check_process(config_path) is None: + with open(log_path, "a") as f: + subprocess.Popen([str(binary_path), "-c", str(config_path)], + stdout=f, stderr=subprocess.STDOUT) + time.sleep(1) + check_process(config_path) + + +def stop_process(config_path): + cmd_str = f"{PROGNAME} -c {config_path}" + print(f"Stopping: {cmd_str}") + pid = check_process(config_path) + if pid: + os.system(f"pkill -SIGTERM -f \"{cmd_str}\"") + time.sleep(1) + + for _ in range(10): + if check_process(config_path) is None: + break + time.sleep(1) + else: + os.system(f"pkill -KILL -U {os.getuid()} -f \"{cmd_str}\"") + + +def main(): + if len(sys.argv) < 3: + print(f"Usage: {sys.argv[0]} [start|stop|check] ") + sys.exit(1) + + command = sys.argv[1].lower() + config_file = get_config_file() + + binary_path, config_path, log_path, basedir = get_paths(config_file) + + source_dats_env() + + if command == "start": + start_process(binary_path, config_path, log_path) + elif command == "stop": + stop_process(config_path) + elif command == "check": + check_process(config_path) + else: + print("Unknown command") + sys.exit(1) + + with open(log_path, "a") as f: + f.write(f"{time.strftime('%Y%m%d.%H%M%S')} run-done : pid,{os.getpid()}\n") + + +if __name__ == "__main__": + main() diff --git a/MatchingEngine/src/Market.cpp b/MatchingEngine/src/Market.cpp index 1414dd45..eb2fa1e7 100644 --- a/MatchingEngine/src/Market.cpp +++ b/MatchingEngine/src/Market.cpp @@ -54,7 +54,7 @@ Market::Market(DataWriterContainerPtr dataWriterContainerPtr, PriceDepthPublisherQueuePtr& price_depth_publisher_queue_ptr) : dataWriterContainerPtr_(dataWriterContainerPtr), _marketName(marketName), _dataServiceName(dataServiceName), - _price_depth_publisher_queue_ptr( price_depth_publisher_queue_ptr ) +_price_depth_publisher_queue_ptr( price_depth_publisher_queue_ptr ), _ready_to_trade(false) { stats_ptr_ = std::make_shared(); } diff --git a/MatchingEngine/src/Market.h b/MatchingEngine/src/Market.h index 93e98c83..24ddf999 100644 --- a/MatchingEngine/src/Market.h +++ b/MatchingEngine/src/Market.h @@ -168,7 +168,8 @@ class Market : public liquibook::book::OrderListener, OrderBookPtr addBook(const std::string &symbol, bool useDepthBook); - bool is_ready_to_trade() { return (books_.size() > 0); }; + bool get_ready_to_trade() { return _ready_to_trade.load(); }; + void set_ready_to_trade( bool ready_to_trade ) { _ready_to_trade.store(ready_to_trade); }; public: @@ -216,6 +217,8 @@ class Market : public liquibook::book::OrderListener, std::string _marketName; // Quickfix field 207 - Security Exchange std::string _dataServiceName; + std::atomic _ready_to_trade; + }; typedef std::shared_ptr market_ptr; diff --git a/MatchingEngine/src/SecurityListDataReaderListenerImpl.cpp b/MatchingEngine/src/SecurityListDataReaderListenerImpl.cpp index 3dd30ca6..66f379ed 100644 --- a/MatchingEngine/src/SecurityListDataReaderListenerImpl.cpp +++ b/MatchingEngine/src/SecurityListDataReaderListenerImpl.cpp @@ -51,7 +51,7 @@ void SecurityListDataReaderListenerImpl::on_data_available( DistributedATS_SecurityList::SecurityList security_list; eprosima::fastdds::dds::SampleInfo info; - if (_marketPtr->is_ready_to_trade()) + if (_marketPtr->get_ready_to_trade() == true) return; if (reader->take_next_sample(&security_list, &info) == eprosima::fastdds::dds::RETCODE_OK) @@ -59,12 +59,16 @@ void SecurityListDataReaderListenerImpl::on_data_available( std::stringstream ss; SecurityListLogger::log(ss, security_list); LOG4CXX_INFO(logger, "SecurityList : [" << ss.str() << "]"); + + std::cout << "Security:" << ss.str() << std::endl; for (uint32_t sec_index = 0; sec_index < security_list.c_NoRelatedSym().size(); sec_index++) { std::string instrument = security_list.c_NoRelatedSym()[sec_index].Symbol(); _marketPtr->addBook(instrument, true); } + + _marketPtr->set_ready_to_trade(true); // request to recieve opening price _marketPtr->publishMarketDataRequest(); diff --git a/MatchingEngine/src/SecurityListRequestDataWriterListener.h b/MatchingEngine/src/SecurityListRequestDataWriterListener.h index de154b56..9afbb0fe 100644 --- a/MatchingEngine/src/SecurityListRequestDataWriterListener.h +++ b/MatchingEngine/src/SecurityListRequestDataWriterListener.h @@ -1,3 +1,9 @@ +#include +#include +#include +#include +#include + #pragma once namespace DistributedATS @@ -5,44 +11,55 @@ namespace DistributedATS class SecurityListRequestDataWriterListener : public eprosima::fastdds::dds::DataWriterListener { - - public: +public: - SecurityListRequestDataWriterListener( const market_ptr& marketPtr ) : matched_(0), _market_ptr(marketPtr) + SecurityListRequestDataWriterListener(const market_ptr& marketPtr) + : matched_(0), _market_ptr(marketPtr), thread_started_(false) { } - ~SecurityListRequestDataWriterListener() override - { - } + ~SecurityListRequestDataWriterListener() override = default; void on_publication_matched( - eprosima::fastdds::dds::DataWriter* dwr, - const eprosima::fastdds::dds::PublicationMatchedStatus& info) override + eprosima::fastdds::dds::DataWriter* dwr, + const eprosima::fastdds::dds::PublicationMatchedStatus& info) override { - if (info.current_count_change >= 1) + if (info.current_count_change > 0) { matched_ = info.total_count; - LOG4CXX_INFO(logger, "SecurityListRequestDataWriterListener Publisher Matched:" << matched_); - if ( !_market_ptr->is_ready_to_trade() ) - _market_ptr->publishSecurityListRequest(dwr); + //std::cout << "[Listener] Publisher Matched: " << matched_ << std::endl; + + // Start thread only once + bool expected = false; + if (thread_started_.compare_exchange_strong(expected, true)) + { + std::thread([this, dwr]() { + while (!_market_ptr->get_ready_to_trade()) + { + //std::cout << "[Listener] Publishing Security Lise Exchange " << matched_ << std::endl; + _market_ptr->publishSecurityListRequest(dwr); + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + }).detach(); + } } else if (info.current_count_change == -1) { matched_ = info.total_count; - LOG4CXX_INFO(logger, "SecurityListRequestDataWriterListener Publisher UnMatched:" << matched_); + std::cout << "[Listener] Publisher UnMatched: " << matched_ << std::endl; } else { - LOG4CXX_INFO(logger, "Is not a valid value for PublicationMatchedStatus current count change." << info.current_count_change); + std::cout << "[Listener] Invalid current_count_change: " << info.current_count_change << std::endl; } } - private: - market_ptr _market_ptr; - std::atomic_int matched_; - }; +private: + market_ptr _market_ptr; + std::atomic_int matched_; + std::atomic thread_started_; // <--- Ensures thread is only started once +}; using security_list_request_data_writer_listener_ptr = std::unique_ptr; -}; +}; // namespace DistributedATS diff --git a/MiscATS/CryptoCLOB/crypto_ats.json b/MiscATS/CryptoCLOB/crypto_ats.json new file mode 100644 index 00000000..3aa71ae8 --- /dev/null +++ b/MiscATS/CryptoCLOB/crypto_ats.json @@ -0,0 +1,10 @@ +[ + ["data_service_manager.py", "data_service_a.ini"], + ["data_service_manager.py", "data_service_b.ini"], + ["matching_engine_manager.py", "matching_engine_MARKET_BTC.ini"], + ["matching_engine_manager.py", "matching_engine_MARKET_ETH.ini"], + ["matching_engine_manager.py", "matching_engine_MARKET_OTHER_COIN.ini"], + ["fix_gateway_manager.py", "fix_gwy_1.cfg"], + ["fix_gateway_manager.py", "fix_gwy_2.cfg"], + ["fix_gateway_manager.py", "fix_gwy_3.cfg"] +] \ No newline at end of file diff --git a/MiscATS/CryptoCLOB/data/distributed_ats.db b/MiscATS/CryptoCLOB/data/distributed_ats.db index 440cc49b..366d8143 100644 Binary files a/MiscATS/CryptoCLOB/data/distributed_ats.db and b/MiscATS/CryptoCLOB/data/distributed_ats.db differ diff --git a/MiscATS/CryptoCLOB/scripts/start_ats.sh b/MiscATS/CryptoCLOB/scripts/start_ats.sh deleted file mode 100755 index aae85eec..00000000 --- a/MiscATS/CryptoCLOB/scripts/start_ats.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -trap cleanup 1 2 3 6 - -cleanup() -{ - echo "Caught Signal ... cleaning up..." - - $BASEDIR_ATS/scripts/stop_ats.sh - - echo "Done." - - exit 1; -} - -sleep 1 -$DATS_HOME/scripts/dataservice.sh start data_service_a.ini - -sleep 1 -$DATS_HOME/scripts/dataservice.sh start data_service_b.ini - -sleep 1 -$DATS_HOME/scripts/matchingengine.sh start matching_engine_MARKET_BTC.ini - -sleep 1 -$DATS_HOME/scripts/matchingengine.sh start matching_engine_MARKET_ETH.ini - -sleep 1 -$DATS_HOME/scripts/matchingengine.sh start matching_engine_MARKET_OTHER_COIN.ini - -sleep 1 -$DATS_HOME/scripts/fixgateway.sh start fix_gwy_1.cfg - -sleep 1 -$DATS_HOME/scripts/fixgateway.sh start fix_gwy_2.cfg - -sleep 1 -$DATS_HOME/scripts/fixgateway.sh start fix_gwy_3.cfg - -while true; do - $DATS_HOME/scripts/dataservice.sh check data_service_a.ini - $DATS_HOME/scripts/dataservice.sh check data_service_b.ini - $DATS_HOME/scripts/matchingengine.sh check matching_engine_MARKET_BTC.ini - $DATS_HOME/scripts/matchingengine.sh check matching_engine_MARKET_ETH.ini - $DATS_HOME/scripts/matchingengine.sh check matching_engine_MARKET_OTHER_COIN.ini - $DATS_HOME/scripts/fixgateway.sh check fix_gwy_1.cfg - $DATS_HOME/scripts/fixgateway.sh check fix_gwy_2.cfg - $DATS_HOME/scripts/fixgateway.sh check fix_gwy_3.cfg - - sleep 2; -done diff --git a/MiscATS/CryptoCLOB/scripts/stop_ats.sh b/MiscATS/CryptoCLOB/scripts/stop_ats.sh deleted file mode 100755 index a439ae62..00000000 --- a/MiscATS/CryptoCLOB/scripts/stop_ats.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -sleep 1 -$DATS_HOME/scripts/dataservice.sh stop data_service_a.ini - -sleep 1 -$DATS_HOME/scripts/dataservice.sh stop data_service_b.ini - -sleep 1 -$DATS_HOME/scripts/matchingengine.sh stop matching_engine_MARKET_BTC.ini - -sleep 1 -$DATS_HOME/scripts/matchingengine.sh stop matching_engine_MARKET_ETH.ini - -sleep 1 -$DATS_HOME/scripts/matchingengine.sh stop matching_engine_MARKET_OTHER_COIN.ini - -sleep 1 -$DATS_HOME/scripts/fixgateway.sh stop fix_gwy_1.cfg - -sleep 1 -$DATS_HOME/scripts/fixgateway.sh stop fix_gwy_2.cfg - -sleep 1 -$DATS_HOME/scripts/fixgateway.sh stop fix_gwy_3.cfg - diff --git a/MiscATS/CryptoCLOB/sql/populate_db.sh b/MiscATS/CryptoCLOB/sql/populate_db.sh index c60e78fd..4c3b259b 100755 --- a/MiscATS/CryptoCLOB/sql/populate_db.sh +++ b/MiscATS/CryptoCLOB/sql/populate_db.sh @@ -1,6 +1,7 @@ #!/bin/sh -$SQLITE_HOME/bin/sqlite3 $DATS_HOME/DataService/sql/sqlite/distributed_ats.db < bash -c "LD_LIBRARY_PATH=/usr/local/lib /usr/local/bin/fastdds discovery -q 51000" @@ -14,9 +14,9 @@ services: container_name: distributed_ats image: ghcr.io/mkipnis/dats_crypto_clob:latest depends_on: - - discovery_service + - fast_dds_discovery command: > - bash -c "cd /usr/local && source ./dats_env.sh && cd $$BASEDIR_ATS/scripts && ./start_ats.sh" + bash -c "cd /usr/local && source ./dats_env.sh && cd MiscATS && BASEDIR_ATS=`pwd`/CryptoCLOB python3 start_ats.py --ats CryptoCLOB/crypto_ats.json" volumes: - ./logs_ats:/usr/local/MiscATS/CryptoCLOB/logs ports: @@ -25,7 +25,6 @@ services: - "17001:17001" restart: unless-stopped - # WebTrader Front-End distributed_ats_webtrader: container_name: distributed_ats_webtrader image: ghcr.io/mkipnis/distributed_ats_webtrader:latest diff --git a/docker/docker-compose-ust.yml b/docker/docker-compose-ust.yml index e6ff1bdf..3e3f49b2 100644 --- a/docker/docker-compose-ust.yml +++ b/docker/docker-compose-ust.yml @@ -14,15 +14,14 @@ services: container_name: distributed_ats image: ghcr.io/mkipnis/dats_ust_clob:latest depends_on: - - discovery_service + - fast_dds_discovery command: > - bash -c "cd /usr/local && source ./dats_env.sh && cd $$BASEDIR_ATS/scripts && ./start_ats.sh" + bash -c "cd /usr/local && source ./dats_env.sh && cd MiscATS && BASEDIR_ATS=`pwd`/USTreasuryCLOB python3 start_ats.py --ats USTreasuryCLOB/ust_ats.json" volumes: - - ./logs_ats:/usr/local/MiscATS/CryptoCLOB/logs + - ./logs_ats:/usr/local/MiscATS/USTreasuryCLOB/logs ports: - "15001:15001" - "16001:16001" - - "17001:17001" restart: unless-stopped # WebTrader Front-End diff --git a/docker/dockerize_dats.sh b/docker/dockerize_dats.sh index 11174fe5..126bce9c 100755 --- a/docker/dockerize_dats.sh +++ b/docker/dockerize_dats.sh @@ -3,10 +3,12 @@ set -x # Core -docker build -t ghcr.io/mkipnis/distributed_ats:latest -f Docker.Build_Distributed_ATS.debug . +docker build -t ghcr.io/mkipnis/distributed_ats_deps:latest -f Docker.Build_DATS_Deps . +docker build -t ghcr.io/mkipnis/distributed_ats:latest -f Docker.Build_Distributed_ATS . docker build --no-cache -t ghcr.io/mkipnis/dats_crypto_clob:latest -f Docker.Crypto_CLOB . docker build --no-cache -t ghcr.io/mkipnis/dats_ust_clob:latest -f Docker.UST_CLOB . -#docker push ghcr.io/mkipnis/distributed_ats:latest -#docker push ghcr.io/mkipnis/dats_crypto_clob:latest -#docker push ghcr.io/mkipnis/dats_ust_clob:latest +docker push ghcr.io/mkipnis/distributed_ats_deps:latest +docker push ghcr.io/mkipnis/distributed_ats:latest +docker push ghcr.io/mkipnis/dats_crypto_clob:latest +docker push ghcr.io/mkipnis/dats_ust_clob:latest diff --git a/docker/start_ust_clob.sh b/docker/start_ust_clob.sh deleted file mode 100755 index 8642b2a0..00000000 --- a/docker/start_ust_clob.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -trap cleanup 1 2 3 6 - -cleanup() -{ - echo "Caught Signal ... cleaning up..." - - $BASEDIR_ATS/scripts/stop_ats.sh - - echo "Done." - - exit 1; -} - -sleep 1 -$DATS_HOME/scripts/matchingengine.sh start matching_engine_MARKET_UST.ini - -sleep 1 -$DATS_HOME/scripts/dataservice.sh start data_service_a.ini -$DATS_HOME/scripts/dataservice.sh start data_service_b.ini - -sleep 1 -$DATS_HOME/scripts/fixgateway.sh start fix_gwy_1.cfg -$DATS_HOME/scripts/fixgateway.sh start fix_gwy_2.cfg - -while true; do - $DATS_HOME/scripts/dataservice.sh check data_service_a.ini - $DATS_HOME/scripts/dataservice.sh check data_service_b.ini - $DATS_HOME/scripts/matchingengine.sh check matching_engine_MARKET_UST.ini - $DATS_HOME/scripts/fixgateway.sh check fix_gwy_1.cfg - $DATS_HOME/scripts/fixgateway.sh check fix_gwy_2.cfg - - sleep 10; -done diff --git a/docker/ust_clob_env.sh b/docker/ust_clob_env.sh deleted file mode 100644 index b200dc3d..00000000 --- a/docker/ust_clob_env.sh +++ /dev/null @@ -1,11 +0,0 @@ -# dependencies -export DATS_HOME=/usr/local -export DEPS_HOME=/usr/local -export LD_LIBRARY_PATH=$DEPS_HOME/lib:$LD_LIBRARY_PATH -export LOG4CXX_CONFIGURATION=$DATS_HOME/config/log4cxx.xml -export FASTDDS_DEFAULT_PROFILES_FILE=/usr/local/FastDDS.xml - -# ATS HOME -export BASEDIR_ATS=$DATS_HOME/MiscATS/USTreasuryCLOB -export DATS_LOG_HOME=$BASEDIR_ATS/logs -mkdir -p $BASEDIR_ATS/logs