set pqf
[yazpp-moved-to-github.git] / etc / yaz-proxy-ka.sh
1 #!/bin/sh
2 # $Id: yaz-proxy-ka.sh,v 1.3 2003-10-24 12:35:37 adam Exp $
3 #
4 # YAZ proxy keepalive wrapper, use this when testing the proxy.
5 #
6 # Allow core dumps when testing.
7 ulimit -c 200000
8 #
9 LOGFILE=/var/log/yaz-proxy-ka.log
10 #
11 touch $LOGFILE || exit 1
12 i=1
13 while test $i -lt 100; do
14         date >>$LOGFILE
15         echo "Starting proxy iteration=$i" >>$LOGFILE
16         yaz-proxy $*
17         code=$?
18         date >>$LOGFILE
19         echo "Proxy Stopped. Exit code=$code" >>$LOGFILE
20         if test "$code" = "143"; then
21                 echo "Got TERM. Exiting" >>$LOGFILE
22                 exit 0
23         fi
24         if test "$code" = "129"; then
25                 echo "Got HUP. Exiting" >>$LOGFILE
26                 exit 0
27         fi
28         if test "$code" = "137"; then
29                 echo "Got KILL. Exiting" >>$LOGFILE
30                 exit 0
31         fi
32         if test "$code" = "0"; then
33                 echo "Exit 0. Exiting" >>$LOGFILE
34                 exit 0
35         fi
36         if test -f core; then
37                 echo "Saving core file" >>$LOGFILE
38                 mv -f core core.`date +%Y%m%d%k%M`
39         fi
40         sleep 1
41         i=`expr $i + 1`
42 done