progress
This commit is contained in:
parent
727ff58c47
commit
972b6aa201
@ -49,20 +49,20 @@ ServicePort=6789
|
|||||||
ServiceDir=${CfgSvcDir}/data
|
ServiceDir=${CfgSvcDir}/data
|
||||||
LogDir=${RootDir}/logs
|
LogDir=${RootDir}/logs
|
||||||
|
|
||||||
|
|
||||||
export PYTHONPATH="${RootDir}:${PYTHONPATH}"
|
export PYTHONPATH="${RootDir}:${PYTHONPATH}"
|
||||||
|
|
||||||
Cmd="nohup"
|
Cmd="nohup"
|
||||||
Cmd="${Cmd} python3"
|
Cmd="${Cmd} python3"
|
||||||
Cmd="${Cmd} ${ServerPy}"
|
Cmd="${Cmd} ${ServerPy}"
|
||||||
Cmd="${Cmd} --port=${ServicePort}"
|
Cmd="${Cmd} --port=${ServicePort}"
|
||||||
|
Cmd="${Cmd} --root=${ServiceDir}"
|
||||||
|
|
||||||
|
|
||||||
function check_it {
|
function check_it {
|
||||||
if !(timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null)
|
if !(timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null)
|
||||||
then
|
then
|
||||||
echo "${Script} doesn't respond. restarting..."
|
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}
|
echo pids=${pids}
|
||||||
if [ "${pids}" != "" ]
|
if [ "${pids}" != "" ]
|
||||||
then
|
then
|
||||||
@ -76,7 +76,7 @@ function check_it {
|
|||||||
function start_it {
|
function start_it {
|
||||||
if !(timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null)
|
if !(timeout 3 curl -s localhost:${AdminPort}/ping > /dev/null)
|
||||||
then
|
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}" != "" ]
|
if [ "${pids}" != "" ]
|
||||||
then
|
then
|
||||||
echo "${0} is already running. pids=(${pids}). Use --restart"
|
echo "${0} is already running. pids=(${pids}). Use --restart"
|
||||||
@ -93,7 +93,7 @@ function start_it {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function 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)
|
pids=$(ps -ef |grep $(basename ${0}) |grep -v ${$} |grep -v grep |tr -s ' ' |cut -d' ' -f2)
|
||||||
|
|
||||||
if [ "${pids}" != "" ]
|
if [ "${pids}" != "" ]
|
||||||
then
|
then
|
||||||
@ -121,15 +121,10 @@ fi
|
|||||||
if [ "${Restart}" == "Y" ]
|
if [ "${Restart}" == "Y" ]
|
||||||
then
|
then
|
||||||
kill_it
|
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
|
fi
|
||||||
|
|
||||||
|
start_it
|
||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
check_it
|
check_it
|
||||||
|
|||||||
@ -13,6 +13,14 @@ do
|
|||||||
Restart=Y
|
Restart=Y
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--stop)
|
||||||
|
Stop="Y"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--once)
|
||||||
|
Once="Y"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--inst_set=*)
|
--inst_set=*)
|
||||||
InstrSet="${arg#*=}"
|
InstrSet="${arg#*=}"
|
||||||
shift
|
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)
|
pids=$(ps -ef |grep "inst_set=${InstrSet}" |grep $(basename ${0}) |grep -v ${$} |grep -v grep |tr -s ' ' |cut -d' ' -f2)
|
||||||
if [ "${Restart}" == "Y" ]
|
if [ "${Restart}" == "Y" ]
|
||||||
then
|
then
|
||||||
|
kill_it
|
||||||
if [ "${pids}" != "" ]
|
if [ "${pids}" != "" ]
|
||||||
then
|
then
|
||||||
echo "Killing ${pids} ..."
|
echo "Killing ${pids} ..."
|
||||||
@ -113,6 +122,7 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
start_it
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
check_it
|
check_it
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user