#!/bin/sh

while :
do

    stillRunning_2=$(ps -e |grep xlink-gw-core-cpp |grep -v "grep")
    if [ "$stillRunning_2" ] ; then
        echo "xlink-gw-core-cpp is running."
    else
        echo "try to start xlink-gw-core-cpp"
        killall xlink-gw-core-cpp
        sleep 1
        cd /home/hj/konkeyunzhiyi/xlink-gw/
        sh start.sh 
    fi
    
    stillRunning_1=$(ps -e |grep xsepproject |grep -v "grep")
    if [ "$stillRunning_1" ] ; then
        echo "xsepproject is running."
    else
        echo "try to start xsepproject"
        killall xsepproject
        sleep 1
        cd /home/hj/konkeyunzhiyi/xlink-gw/
        sh start.sh 
    fi
    sleep 10

    stillRunning_0=$(ps -e |grep konkeyunzhiyi |grep -v "grep" |grep -v "check_konkeyunzhiyi")
    if [ "$stillRunning_0" ] ; then
        echo "konkeyunzhiyi is running."
    else
        echo "try to start konkeyunzhiyi"
        killall konkeyunzhiyi
        sleep 1
        cd /home/hj/konkeyunzhiyi/bin/
        sh start.sh 
    fi  
    
    sleep 50
done
