summaryrefslogtreecommitdiff
path: root/bin/checkalive.sh
blob: 91c498af51d57067d299ed3ef9ab4240cea89210 (plain)
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
#!/bin/bash

# for a production environment with high-availability requirement,
# (and if you are using the debian version of yacy)
# add the following line in /etc/crontab
# 0 *	* * *	yacy    cd /usr/share/yacy/bin && ./checkalive.sh

port=$(grep ^port= ../DATA/SETTINGS/yacy.conf |cut -d= -f2)
RESULT=`wget -t 1 --spider http://localhost:$port/Status.html 2>&1`
FLAG=0

for x in $RESULT; do
    if [ "$x" = '200' ]; then
        FLAG=1
    fi
done

if [ $FLAG -eq '0' ]; then
    cd ..
    timeout 30s ./stopYACY.sh
    ./killYACY.sh
    rm DATA/yacy.running
    ./startYACY.sh
fi

exit