#!/bin/sh

PID_FILE=%%%SUBDIR%%%/logs/pid
if test -f $PID_FILE ; then
	kill `cat $PID_FILE`
	if test $? -ne 0 ; then
		exit 1
	fi
else
	echo server not running
	exit 1
fi

loop_counter=1
max_count=30
while test $loop_counter -le $max_count; do
	loop_counter=`expr $loop_counter + 1`
	if test -f $PID_FILE ; then
		sleep 2
	else
		exit 0
	fi
done
echo server not responding to exit command
echo killing process group
kill -9 -`cat $PID_FILE`
rm $PID_FILE

exit 1
