This commit is contained in:
Oleg Sheynin 2023-04-29 16:45:37 -04:00
parent 5a8ce24ad1
commit ee3f7dc218
2 changed files with 39 additions and 15 deletions

View File

@ -1 +1 @@
0.1.2.1
0.1.3

View File

@ -2,7 +2,7 @@
Script="${0} ${*}"
function usage {
echo "Usage: ${0} --inst_set=<setting #> [--restart] [--sleep_sec=<num_seconds>]"
echo "Usage: ${0} --inst_set=<setting #> [--restart] [--stop] [--once] [--sleep_sec=<num_seconds>]"
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
}
function kill_it {
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
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
done
else
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
echo "${0} is already running. pids=(${pids}). Use --restart"
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
@ -129,3 +151,5 @@ do
echo "${Script} is checked" | /usr/bin/ts '[%Y-%m-%d %H:%M:%S]'
sleep ${SleepSec}
done