#!/bin/sh
#判断进程是否存在，如果不存在就启动它
while true
do
sleep 30
PIDS=`ps|grep kk_midware |grep -v grep | awk '{print $1}'`
if [ "$PIDS" != "" ]; then
	echo "kk_midware is runing!"
else
	/home/kk/kk_midware >/dev/null 2>&1 &
#运行进程
fi
sleep 30
PIDS=`ps|grep kcloud |grep -v grep | awk '{print $1}'`
if [ "$PIDS" != "" ]; then
	echo "kcloud is runing!"
else
	echo "kcloud is not running ,now restart kk_midware and kcloud"
	pgrep kk_midware | xargs kill -s 9
	/home/kk/kk_midware >/dev/null 2>&1 &
	/home/kk/kcloud >/dev/null 2>&1 &
fi
sleep 30
PIDS=`ps|grep Z3GatewayHost |grep -v grep | awk '{print $1}'`
if [ "$PIDS" != "" ]; then
	echo "Z3GatewayHost is runing!"
else
	echo "Z3GatewayHost is not running ,now restart Z3GatewayHost"
	pgrep Z3GatewayHost | xargs kill -s 9
	/home/kk/Z3GatewayHost -f x -p /dev/ttyS0 >/dev/null 2>&1 &
fi
done
