From 3190cf5d4dc558cee74766dfed4b0e462b9a67f6 Mon Sep 17 00:00:00 2001 From: Oleg Sheynin Date: Fri, 13 Dec 2024 13:41:37 -0500 Subject: [PATCH] musvcs progress --- microservices/docker-compose.yml | 9 +++-- microservices/md_gateway/run_mdgw.sh | 16 ++------ microservices/tester/.dockerignore | 3 ++ microservices/tester/Dockerfile | 26 +++++++++++++ microservices/tester/run_tester.sh | 55 ++++++++++++++++++++++++++++ release_version.txt | 2 +- 6 files changed, 94 insertions(+), 17 deletions(-) create mode 100644 microservices/tester/.dockerignore create mode 100644 microservices/tester/Dockerfile create mode 100755 microservices/tester/run_tester.sh diff --git a/microservices/docker-compose.yml b/microservices/docker-compose.yml index 84828cf..aaa33ca 100644 --- a/microservices/docker-compose.yml +++ b/microservices/docker-compose.yml @@ -9,6 +9,7 @@ services: volumes: - ./config:/shared/config - ./logs:/shared/logs + - ./data:/data depends_on: - redis @@ -16,12 +17,12 @@ services: image: redis:latest container_name: redis ports: - - "6379:6379" - volumes: - - redis_data:/data + - "6379:6379" + volumes: + - redis_data:/data/redis volumes: - redis_data: + redis_data: # version: "3.9" # services: diff --git a/microservices/md_gateway/run_mdgw.sh b/microservices/md_gateway/run_mdgw.sh index b68481b..e278787 100755 --- a/microservices/md_gateway/run_mdgw.sh +++ b/microservices/md_gateway/run_mdgw.sh @@ -5,29 +5,23 @@ # runs on host to start container usage() { echo -n "Usage: ${0}" - echo -n " [-c ]" - echo -n " [-e ]" + echo -n " [-c ]" echo -n " [-a ]" - echo -n " [-n ]" echo -n " [-z (compress log)"] echo exit 1 } Config=/config/cvtt.cfg -ActiveExchanges=ALPACA_SNDBX -PortalName=MD_PORTAL_ALPACA_SNDBX AdminPort=7220 COMPRESS_LOG=false -while getopts "c:e:a:n:z" opt; do +while getopts "c:a:z" opt; do case ${opt} in c ) Config=$OPTARG ;; - e ) ActiveExchanges=$OPTARG ;; a ) AdminPort=$OPTARG ;; z ) COMPRESS_LOG=true ;; - n ) PortalName=$OPTARG ;; \? ) echo "Invalid option: -$OPTARG" >&2 usage @@ -43,11 +37,9 @@ Cmd="python3.12" Cmd="${Cmd} cvttpy/apps/microservices/mkt_data_gateway/md_gateway.py" Cmd="${Cmd} --config=${Config}" Cmd="${Cmd} --credentials_file=/.creds" -Cmd="${Cmd} --active_exchanges=${ActiveExchanges}" -Cmd="${Cmd} --portal_name=${PortalName}" Cmd="${Cmd} --admin_port=${AdminPort}" -Cmd="${Cmd} --log_file=/logs/%T.${PortalName}.log" -if ${COMPRESS_LOG}; then +Cmd="${Cmd} --log_file=/logs/%T.md_gateway.log" +if ${COMPRESS_LOG} ; then Cmd="${Cmd} --compress_log" fi echo ${Cmd} diff --git a/microservices/tester/.dockerignore b/microservices/tester/.dockerignore new file mode 100644 index 0000000..a4f7c14 --- /dev/null +++ b/microservices/tester/.dockerignore @@ -0,0 +1,3 @@ +.git +**/__pycache__ +.pipenv \ No newline at end of file diff --git a/microservices/tester/Dockerfile b/microservices/tester/Dockerfile new file mode 100644 index 0000000..0a3439e --- /dev/null +++ b/microservices/tester/Dockerfile @@ -0,0 +1,26 @@ +FROM python:3.12-slim + +ARG ROOT_MUSVC_DIR=docker_dev/microservices +ARG FROM_DIR=${ROOT_MUSVC_DIR}/tester + +COPY ${ROOT_MUSVC_DIR}/requirements.txt / +RUN pip install --upgrade pip --root-user-action=ignore +RUN pip install -r /requirements.txt --root-user-action=ignore + +COPY cvttpy /cvttpy +COPY ${ROOT_MUSVC_DIR}/.creds /.creds + + +COPY ${FROM_DIR}/run_tester.sh /run_tester.sh +RUN chmod +x /run_tester.sh + +RUN mkdir /logs +RUN mkdir -p /config +RUN mkdir -p /data + + +WORKDIR / +SHELL ["/bin/bash", "-c"] +ENV PYTHONPATH=/ +ENTRYPOINT [ "/run_tester.sh" ] + diff --git a/microservices/tester/run_tester.sh b/microservices/tester/run_tester.sh new file mode 100755 index 0000000..748ff4a --- /dev/null +++ b/microservices/tester/run_tester.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# runs in container + +# runs on host to start container +usage() { + echo -n "Usage: ${0}" + echo -n " [-c ]" + echo -n " [-i ]" + echo -n " [-d ]" + echo -n " [-a ]" + echo -n " [-z (compress log (false))"] + echo + exit 1 +} + +Config=/config/cvtt.cfg +AdminPort=7221 +COMPRESS_LOG=false +Instruments="COINBASE:PAIR-BTC-USD,BNBFUT:PERP-BTC-USDT" +DataTypes="TRADES" + +while getopts "a:c:d:i:z" opt; do + case ${opt} in + c ) Config=$OPTARG ;; + a ) AdminPort=$OPTARG ;; + i ) Instruments=$OPTARG ;; + d ) DataTypes=$OPTARG ;; + z ) COMPRESS_LOG=true ;; + \? ) + echo "Invalid option: -$OPTARG" >&2 + usage + ;; + : ) + echo "Option -$OPTARG requires an argument." >&2 + usage + ;; + esac +done + +Cmd="python3.12" +Cmd="${Cmd} cvttpy/apps/microservices/tester/musvc_tester.py" +Cmd="${Cmd} --config=${Config}" +Cmd="${Cmd} --credentials_file=/.creds" +Cmd="${Cmd} --admin_port=${AdminPort}" +Cmd="${Cmd} --data_types=${DataTypes}" +Cmd="${Cmd} --instruments=${Instruments}" +Cmd="${Cmd} --log_file=/logs/%T.tester.log" +if ${COMPRESS_LOG} ; then + Cmd="${Cmd} --compress_log" +fi +echo ${Cmd} +eval ${Cmd} + + diff --git a/release_version.txt b/release_version.txt index 3deea0a..86030f5 100644 --- a/release_version.txt +++ b/release_version.txt @@ -1 +1 @@ -0.0.5,16->23 \ No newline at end of file +0.0.6,musvcs progress \ No newline at end of file