blob: 5258f276219eb6313c6eb8809790646510f5d571 (
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
27
28
29
30
31
32
33
34
35
36
|
#!/bin/bash
exec 2>&1
export TERM=linux
. /etc/rc.conf
. /etc/rc.d/functions
function cleanup(){
rm -f /etc/sv/mythbackend/.runtime/*
printhl " Cleaning up /etc/sv/mythbackend/.runtime/"
}
if [ ! -d /etc/sv/mythbackend/.runtime ]
then
mkdir -p /etc/sv/mythbackend/.runtime
fi
touch /etc/sv/mythbackend/.runtime/`date +%s`
sleep 0.2
cdate=`date`
numfilestotal=`/usr/bin/file_time_offset.py -s0 -d/etc/sv/mythbackend/.runtime`
numfilesover10secondsold=`/usr/bin/file_time_offset.py -s10 -d/etc/sv/mythbackend/.runtime`
numfileslessthan10secondsold=$(($numfilestotal-$numfilesover10secondsold))
if [ $numfileslessthan10secondsold -gt 4 ]
then
sv stop mythbackend
printhl " mythbackend disabled, due to many restarts."
logger " mythbackend disabled, due to many restarts."
printhl " Run \"sv start mythbackend\" to try again"
cleanup
else
if [ $numfilestotal -gt 10 ]
then
cleanup
fi
fi
|