progress
This commit is contained in:
parent
a8ccf8c48d
commit
1227036c80
@ -1 +1 @@
|
||||
0.2.1
|
||||
0.2.2
|
||||
|
||||
156
scripts/bnbspot_md_recorder_start.sh
Executable file
156
scripts/bnbspot_md_recorder_start.sh
Executable file
@ -0,0 +1,156 @@
|
||||
#!/bin/bash
|
||||
Script="${0} ${*}"
|
||||
|
||||
function usage {
|
||||
echo "Usage: ${0} --inst_set=<setting #> [--restart] [--stop] [--once] [--sleep_sec=<num_seconds>]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
for arg in "${@}"
|
||||
do
|
||||
case ${arg} in
|
||||
--restart)
|
||||
Restart=Y
|
||||
shift
|
||||
;;
|
||||
--stop)
|
||||
Stop="Y"
|
||||
shift
|
||||
;;
|
||||
--once)
|
||||
Once="Y"
|
||||
shift
|
||||
;;
|
||||
--inst_set=*)
|
||||
InstrSet="${arg#*=}"
|
||||
shift
|
||||
;;
|
||||
--sleep_sec=*)
|
||||
SleepSec="${arg#*=}"
|
||||
shift
|
||||
;;
|
||||
-*|--*)
|
||||
usage
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
declare -A InstrSetInstrs
|
||||
InstrSetInstrs[1]=PAIR-BTC-USDT,PAIR-ETH-USDT,PAIR-LTC-USDT,PAIR-XRP-USDT,PAIR-USDT-USD
|
||||
|
||||
|
||||
if [ "${InstrSet}" == "" ]
|
||||
then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ "${SleepSec}" == "" ]
|
||||
then
|
||||
SleepSec=3
|
||||
fi
|
||||
|
||||
Instruments=${InstrSetInstrs[${InstrSet}]}
|
||||
if [ "${Instruments}" == "" ]
|
||||
then
|
||||
echo "Unrecognized instrument settings: ${InstrSet}"
|
||||
usage
|
||||
fi
|
||||
|
||||
# -------------------- S e t t i n g s
|
||||
RootDir=/home/cvtt/prod
|
||||
# ConfigFile="${RootDir}/config/md_recorder.cfg"
|
||||
ConfigFile="http://cloud11.cvtt.vpn:6789/apps/md_recorder"
|
||||
|
||||
AdminPort="721${InstrSet}"
|
||||
Exchange=BNBSPOT
|
||||
DbCredKey=TSDB_COINBS_1
|
||||
Name=MD_RECORDER_BNBSPOT
|
||||
# -------------------- S e t t i n g s
|
||||
|
||||
LogFile="${RootDir}/logs/$(date '+%Y%m%d_%H%M%S').${Name}_${InstrSet}.log"
|
||||
|
||||
source ${HOME}/.pyenv/python3.10-venv/bin/activate
|
||||
export PYTHONPATH=${RootDir}
|
||||
|
||||
Cmd="nohup"
|
||||
Cmd="${Cmd} python3"
|
||||
Cmd="${Cmd} ${RootDir}/cvttpy/apps/md_recorder.py"
|
||||
Cmd="${Cmd} --config=${ConfigFile}"
|
||||
Cmd="${Cmd} --active_exchanges=${Exchange}"
|
||||
Cmd="${Cmd} --instruments=${Instruments}"
|
||||
Cmd="${Cmd} --admin_port=${AdminPort}"
|
||||
Cmd="${Cmd} --log_level=INFO"
|
||||
Cmd="${Cmd} --log_file=${LogFile}"
|
||||
Cmd="${Cmd} --db_credentials_key=${DbCredKey}"
|
||||
Cmd="${Cmd} &"
|
||||
|
||||
function start_it {
|
||||
echo ${Cmd}
|
||||
eval ${Cmd} &
|
||||
sleep 10
|
||||
}
|
||||
|
||||
|
||||
function check_it {
|
||||
|
||||
if !(timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null)
|
||||
then
|
||||
echo "${Script} doesn't respond. restarting..."
|
||||
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
|
||||
start_it
|
||||
fi
|
||||
}
|
||||
|
||||
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} ..."
|
||||
kill -9 ${pids}
|
||||
fi
|
||||
while (timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null)
|
||||
do
|
||||
echo "Shutting down 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
|
||||
}
|
||||
|
||||
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
|
||||
while true
|
||||
do
|
||||
check_it
|
||||
echo "${Script} is checked" | /usr/bin/ts '[%Y-%m-%d %H:%M:%S]'
|
||||
sleep ${SleepSec}
|
||||
done
|
||||
@ -70,7 +70,7 @@ ConfigFile="http://cloud11.cvtt.vpn:6789/apps/md_recorder"
|
||||
AdminPort="720${InstrSet}"
|
||||
Exchange=COINBASE_AT
|
||||
DbCredKey=TSDB_COINBS_1
|
||||
Name=md_recorder_coinbase
|
||||
Name=MD_RECORDER_COINBASE
|
||||
# -------------------- S e t t i n g s
|
||||
|
||||
LogFile="${RootDir}/logs/$(date '+%Y%m%d_%H%M%S').${Name}_${InstrSet}.log"
|
||||
Loading…
x
Reference in New Issue
Block a user