Obsoleted util/watch_sphinx_main_index.sh by refactoring indexer.main.sh

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2020-11-13 21:08:11 +01:00
parent f7cc52433c
commit 9225d5b32e
4 changed files with 32 additions and 22 deletions

View File

@ -6,7 +6,6 @@
*/15 * * * * /usr/bin/indexer --config SYSCONFDIR/piler/sphinx.conf --quiet note1 --rotate
*/5 * * * * /usr/bin/find LOCALSTATEDIR/piler/www/tmp -type f -name i.\* -exec rm -f {} \;
*/5 * * * * /usr/bin/find LOCALSTATEDIR/piler/error -type f|wc -l > LOCALSTATEDIR/piler/stat/error
3 * * * * LIBEXECDIR/piler/watch_sphinx_main_index.sh
2 0 * * * LIBEXECDIR/piler/pilerpurge.py
### optional: populate accouting data

View File

@ -46,7 +46,6 @@ install:
$(INSTALL) -m 0755 $(srcdir)/purge.sh $(DESTDIR)$(libexecdir)/piler
$(INSTALL) -m 0755 $(srcdir)/pilerpurge.py $(DESTDIR)$(libexecdir)/piler
$(INSTALL) -m 0755 $(srcdir)/postinstall.sh $(DESTDIR)$(libexecdir)/piler
$(INSTALL) -m 0755 $(srcdir)/watch_sphinx_main_index.sh $(DESTDIR)$(libexecdir)/piler
$(INSTALL) -m 0755 $(srcdir)/db-mysql.sql $(DESTDIR)$(datarootdir)/piler
$(INSTALL) -m 0755 $(srcdir)/db-mysql-root.sql.in $(DESTDIR)$(datarootdir)/piler

View File

@ -1,34 +1,49 @@
#!/bin/bash
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
MAINTMPFILE=/var/run/piler/main.indexer.tmp
INDEXER="indexer --config SYSCONFDIR/piler/sphinx.conf"
PRIORITY=mail.error
TOUCHFILE=/var/piler/stat/indexer
set -o nounset
set -o errexit
set -o pipefail
if [ -f $MAINTMPFILE ]; then echo "INDEXER ERROR: indexer merging to main index is already running. It started at "`cat $MAINTMPFILE` | logger -p $PRIORITY ; exit 1; fi
MAINTMPFILE="/var/run/piler/main.indexer.tmp"
SPHINX_CONFIG="SYSCONFDIR/piler/sphinx.conf"
PRIORITY="mail.error"
TOUCHFILE="/var/piler/stat/indexer"
MAIN_INDEX="main1"
date > $MAINTMPFILE
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
touch $TOUCHFILE
function finish {
rm -f $MAINTMPFILE
finish() {
rm -f "$MAINTMPFILE"
}
if [[ -f "$MAINTMPFILE" ]]; then
echo "INDEXER ERROR: indexer merging to main index is already running. It started at $(cat "$MAINTMPFILE")" | logger -p "$PRIORITY"
exit 1
fi
date > "$MAINTMPFILE"
touch "$TOUCHFILE"
trap finish EXIT
echo "INDEXER INFO: merging to main started" | logger -p $PRIORITY
echo "INDEXER INFO: merging to main started" | logger -p "$PRIORITY"
$INDEXER --quiet --merge main1 dailydelta1 --merge-dst-range deleted 0 0 --rotate
indexer --config "$SPHINX_CONFIG" --quiet --merge "$MAIN_INDEX" dailydelta1 --merge-dst-range deleted 0 0 --rotate
echo "INDEXER INFO: merging to main finished" | logger -p $PRIORITY
echo "INDEXER INFO: merging to main finished" | logger -p "$PRIORITY"
sleep 5
echo "INDEXER INFO: resetting daily delta started" | logger -p $PRIORITY
echo "INDEXER INFO: resetting daily delta started" | logger -p "$PRIORITY"
$INDEXER --quiet dailydelta1 --rotate
indexer --config "$SPHINX_CONFIG" --quiet dailydelta1 --rotate
echo "INDEXER INFO: resetting daily delta finished" | logger -p $PRIORITY
echo "INDEXER INFO: resetting daily delta finished" | logger -p "$PRIORITY"
sum=0
while read -r a b; do
sum=$(( sum + b ))
done < <( find /var/piler/sphinx/ -type f -name main\*.spd -printf "%TY%Tm%Td %s\\n" )
printf "%d" $sum > /var/piler/stat/main_index_size

View File

@ -1,3 +0,0 @@
#!/bin/bash
find /var/piler/sphinx/ -type f -name main\*.spd -printf "%TY%Tm%Td %s\\n" | sort -r | head -1 | cut -f2 -d ' ' > /var/piler/stat/main_index_size