File: squid.RunCache

package info (click to toggle)
squid 1.1.21-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 2,828 kB
  • ctags: 3,705
  • sloc: ansic: 34,400; sh: 1,975; perl: 899; makefile: 559
file content (59 lines) | stat: -rw-r--r-- 1,205 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
#
#  $Id: RunCache.in,v 1.3.2.4 1996/05/24 06:40:39 wessels Exp $

prefix=/usr/lib/squid
exec_prefix=${prefix}
[ "$logdir" = "" ] && logdir=$prefix
PIDFILE=/var/run/runcache.pid
PATH=${exec_prefix}:/bin:/sbin:/usr/sbin:/usr/bin
export PATH

#
#	Just to be sure, check if squid is not already running.
#
if [ -f /var/run/squid.pid ]
then
	spid=`cat /var/run/squid.pid`
	kill -CONT $spid 2>/dev/null
	if [ $? = 0 ]
	then
		#echo "RunCache: squid is already running." >&2
		exit 0
	fi
fi

rm -f $PIDFILE
echo $$ > $PIDFILE

L=$logdir/squid.out

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

failcount=0
while : ; do
	echo "`date`: Running: squid -D -s $conf >> $L 2>&1" >>$L
	if [ $failcount -gt 0 ]
	then
	  echo "`date`: Running: squid -D -s $conf >> $L 2>&1"
	fi
	start=`date '+%d%H%M%S'`
	squid -D -s $conf >> $L 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 "`date`: RunCache: EXITING DUE TO REPEATED FREQUENT FAILURES" >&2
          echo "`date`: RunCache: EXITING DUE TO REPEATED FREQUENT FAILURES" >$L
	  exit 1
	fi
	sleep 10
done