#!/bin/sh
RESOURCE_NAME=v4_main_bitcoin_grid.py
tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Stop Process...'
kill -15 $tpid
fi
sleep 5
tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
echo 'Stop Success!'
fi
while true ; do
tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'App is running.'
sleep 5s
else
echo 'App is NOT running.'
rm -f tpid
nohup python3 /opt/workspace/BA2/marketTrade/bitcoin_240/$RESOURCE_NAME 1h 3 True >/dev/null 2>&1 &
echo $! > tpid
echo Start Success!
fi
done
exit 0