#!/bin/sh
#
#  $Id: RunAccel.in,v 1.7 2003/01/23 00:37:06 robertc Exp $

# enable HTTP requests on port 80
port="-a 80"

prefix=/usr
exec_prefix=${prefix}
logdir=/var/log/squid
PATH=${exec_prefix}/sbin:/bin:/usr/bin
export PATH

if test $# = 1 ; then
	conf="-f $1"
	shift
fi

failcount=0
while : ; do
	echo "Running: squid $port -s $conf >> $logdir/squid.out 2>&1"
	start=`date '+%d%H%M%S'`
	squid -N $port -s $conf >> $logdir/squid.out 2>&1
	stop=`date '+%d%H%M%S'`
	t=`expr $stop - $start`
	if test 0 -le $t -a $t -lt 5 ; then
		failcount=`expr $failcount + 1`
	else
		failcount=0
	fi
	if test $failcount -gt 5 ; then
              echo "RunCache: EXITING DUE TO REPEATED, FREQUENT FAILURES" >&2
		exit 1
	fi
	sleep 10
done
