#!/bin/bash

sleep 60
WEB_SERVER_ROOT=$1
export WEB_SERVER_ROOT
while :
do
	count=`ps -aef | grep "uxwdog -d $WEB_SERVER_ROOT" | grep -v "grep" | wc -l`
	if [ $count -eq 0 ]
	then 
		sleep 120
	else
		if [ ! -f $WEB_SERVER_ROOT/.egurkha ] 
		then
			sleep 120
		else
			pid=`cat $WEB_SERVER_ROOT/.egurkha | grep File | cut -f2 -d '.'`
			val=`ps -p $pid | grep $pid | wc -l`
			if [ $val -eq 0 ]
			then
				$WEB_SERVER_ROOT/stop.egurkha
				$WEB_SERVER_ROOT/start
				exit
			else
				sleep 120
			fi
		fi
	fi
done

