This commit is contained in:
Oleg Sheynin 2023-04-23 23:17:23 -04:00
parent 727ff58c47
commit 972b6aa201
2 changed files with 16 additions and 11 deletions

View File

@ -49,20 +49,20 @@ ServicePort=6789
ServiceDir=${CfgSvcDir}/data
LogDir=${RootDir}/logs
export PYTHONPATH="${RootDir}:${PYTHONPATH}"
Cmd="nohup"
Cmd="${Cmd} python3"
Cmd="${Cmd} ${ServerPy}"
Cmd="${Cmd} --port=${ServicePort}"
Cmd="${Cmd} --root=${ServiceDir}"
function check_it {
if !(timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null)
then
echo "${Script} doesn't respond. restarting..."
pids=$(ps -ef | grep "--port=${ServicePort}" | grep -v grep | tr -s ' ' |cut -d' ' -f2)
pids=$(ps -ef | grep "port=${ServicePort}" | grep "root=${ServiceDir}" | grep -v grep | tr -s ' ' |cut -d' ' -f2)
echo pids=${pids}
if [ "${pids}" != "" ]
then
@ -76,7 +76,7 @@ function check_it {
function start_it {
if !(timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null)
then
pids=$(ps -ef | grep "--port=${ServicePort}" | grep -v grep | tr -s ' ' |cut -d' ' -f2)
pids=$(ps -ef |grep $(basename ${0}) |grep -v ${$} |grep -v grep |tr -s ' ' |cut -d' ' -f2)
if [ "${pids}" != "" ]
then
echo "${0} is already running. pids=(${pids}). Use --restart"
@ -93,7 +93,7 @@ function start_it {
}
function kill_it {
pids=$(ps -ef |grep "inst_set=${InstrSet}" |grep $(basename ${0}) |grep -v ${$} |grep -v grep |tr -s ' ' |cut -d' ' -f2)
pids=$(ps -ef |grep $(basename ${0}) |grep -v ${$} |grep -v grep |tr -s ' ' |cut -d' ' -f2)
if [ "${pids}" != "" ]
then
@ -121,15 +121,10 @@ fi
if [ "${Restart}" == "Y" ]
then
kill_it
else
pids=$(ps -ef |grep "inst_set=${InstrSet}" |grep $(basename ${0}) |grep -v ${$} |grep -v grep |tr -s ' ' |cut -d' ' -f2)
if [ "${pids}" != "" ]
then
echo "${0} is already running. pids=(${pids}). Use --restart"
exit 0
fi
fi
start_it
while true
do
check_it

View File

@ -13,6 +13,14 @@ do
Restart=Y
shift
;;
--stop)
Stop="Y"
shift
;;
--once)
Once="Y"
shift
;;
--inst_set=*)
InstrSet="${arg#*=}"
shift
@ -95,6 +103,7 @@ function check_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} ..."
@ -113,6 +122,7 @@ else
fi
fi
start_it
while true
do
check_it