From ee3f7dc21819fb00434a7887f6fd1bb2aa8a17c2 Mon Sep 17 00:00:00 2001 From: Oleg Sheynin Date: Sat, 29 Apr 2023 16:45:37 -0400 Subject: [PATCH] progress --- release_version.txt | 2 +- scripts/md_recorder_start.sh | 52 ++++++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/release_version.txt b/release_version.txt index c51ed87..7693c96 100644 --- a/release_version.txt +++ b/release_version.txt @@ -1 +1 @@ -0.1.2.1 \ No newline at end of file +0.1.3 \ No newline at end of file diff --git a/scripts/md_recorder_start.sh b/scripts/md_recorder_start.sh index 18bb124..20accca 100755 --- a/scripts/md_recorder_start.sh +++ b/scripts/md_recorder_start.sh @@ -2,7 +2,7 @@ Script="${0} ${*}" function usage { - echo "Usage: ${0} --inst_set= [--restart] [--sleep_sec=]" + echo "Usage: ${0} --inst_set= [--restart] [--stop] [--once] [--sleep_sec=]" exit 1 } @@ -70,6 +70,7 @@ AdminPort="720${InstrSet}" LogFile="${RootDir}/mmaker/logs/$(date '+%Y%m%d_%H%M%S').influx_rec.coinbs_${InstrSet}.log" Exchange=COINBASE +source ${HOME}/.pyenv/python3.10-venv/bin/activate export PYTHONPATH=${RootDir} Cmd="nohup" @@ -83,6 +84,12 @@ Cmd="${Cmd} --log_level=INFO" Cmd="${Cmd} --log_file=${LogFile}" Cmd="${Cmd} &" +function start_it { + echo ${Cmd} + eval ${Cmd} & + sleep 10 +} + function check_it { @@ -95,15 +102,13 @@ function check_it { then kill -9 ${pids} fi - echo ${Cmd} - eval ${Cmd} && sleep 10 + start_it fi } -pids=$(ps -ef |grep "inst_set=${InstrSet}" |grep $(basename ${0}) |grep -v ${$} |grep -v grep |tr -s ' ' |cut -d' ' -f2) -if [ "${Restart}" == "Y" ] -then - kill_it +function kill_it { + pids=$(ps -ef |grep "inst_set=${InstrSet}" |grep $(basename ${0}) |grep -v ${$} |grep -v grep |tr -s ' ' |cut -d' ' -f2) + if [ "${pids}" != "" ] then echo "Killing ${pids} ..." @@ -112,14 +117,31 @@ then while (timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null) do echo "Shutting down localhost:${AdminPort}/shutdown ..." - timeout 10 curl -s localhost:${AdminPort}/shutdown + timeout 5 curl -s localhost:${AdminPort}/shutdown + + pids=$(ps -ef | grep "admin_port=${AdminPort}" | grep -v grep | tr -s ' ' |cut -d' ' -f2) + echo pids=${pids} + if [ "${pids}" != "" ] + then + kill -9 ${pids} + fi done -else - if [ "${pids}" != "" ] - then - echo "${0} is already running. pids=(${pids}). Use --restart" - exit 0 - fi +} + +if [ "${Stop}" == "Y" ] ; then + kill_it + exit 0 +fi + +if [ "${Once}" == "Y" ] ; then + start_it + exit 0 +fi + + +if [ "${Restart}" == "Y" ] +then + kill_it fi start_it @@ -129,3 +151,5 @@ do echo "${Script} is checked" | /usr/bin/ts '[%Y-%m-%d %H:%M:%S]' sleep ${SleepSec} done + +